最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how can I replace %23 with # in url? - Stack Overflow

programmeradmin1浏览0评论

when I click on submit button url is:

http://localhost/college/index.php?field=1&exam=ATMA&submit3=%23success

I want to replace this link with:

http://localhost/college/index.php?field=1&exam=ATMA&submit3=#success

How can I do this ?

when I click on submit button url is:

http://localhost/college/index.php?field=1&exam=ATMA&submit3=%23success

I want to replace this link with:

http://localhost/college/index.php?field=1&exam=ATMA&submit3=#success

How can I do this ?

Share Improve this question asked Jan 17, 2017 at 10:06 sam ortensam orten 2064 silver badges18 bronze badges 1
  • 2 When you submit, is your backend expecting the value for submit3 to be #success? If so, don't change it, handle it in the backend. A # has special meaning. it would be like trying to get submit3=&success to have submit3 = &success - you'd need to encode the & in the same way that # is encoded here. – fdomn-m Commented Jan 17, 2017 at 10:10
Add a ment  | 

2 Answers 2

Reset to default 3

The functions you are looking for are

PHP:

urlencode($string);
urldecode($string);

Javascript:

decodeURIComponent(string);
encodeURIComponent(string);

Try the following decodeURIComponent:

decodeURIComponent('http://localhost/college/index.php?field=1&exam=ATMA&submit3=%23success')
发布评论

评论列表(0)

  1. 暂无评论