【发布时间】:2014-06-24 02:42:15
【问题描述】:
是否可以更改 url 栏中的参数,以便单击参数以进行更改?到目前为止,我有这个:
function change_product(){
var url = 'http://www.example.com/index.php?product=805';
var newSrc = '0';
newurl=url.replace(/(product=)[^\&]+/,'$1' + newSrc)
alert(newurl);
}
<button class="save" type="BUTTON" onclick="change_product();">Copy</button>
newurl 是正确的,但如何在 url 栏中更改?没有页面重新加载是否有可能? 提前致谢!
【问题讨论】:
-
在建议的答案中我只看到重新加载解决方案
-
没有。 location.hash 和 pushstate 都在建议的副本中
标签: javascript jquery url url-rewriting