如何在网址中用#替换%23?

时间:2017-01-17 10:06:59

标签: javascript php jquery html5 css3

当我点击提交按钮时,网址为:

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

我想用以下内容替换此链接:

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

我该怎么做?

2 个答案:

答案 0 :(得分:2)

您正在寻找的功能是

PHP:

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

使用Javascript:

decodeURIComponent(string);
encodeURIComponent(string);

答案 1 :(得分:0)

尝试以下decodeURIComponent

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