替换URL而不重定向

时间:2016-07-30 18:38:40

标签: javascript html

从网址中删除哈希#(不带重定向)

location.hash = "?userid=" + document.getElementById("userid").innerHTML;
location.href.replace('#', '');

编辑:答案= window.history.pushState("","",window.location.href +"?userid =" +文件.getElementById("用户ID&#34)。innerHTML的);

1 个答案:

答案 0 :(得分:1)

window.history.pushState("", "", window.location.href +  "?userid=" + document.getElementById("userid").innerHTML);