我有这个网址:
website.com/con?blog=true
我在 javascript 中所做的是:
if (getURLparams(blog)) {
RandomFunction();
// change the url
window.history.replaceState({}, '?blog=true', "blog=false");
}
但是,我不想使用
blog=false
,实际上我想要空字符串。我试过 ""
/''
但它们没有用。任何想法或替代方案?谢谢
最佳答案
您可以将其设置为 location.pathname
:
window.history.replaceState({}, '', location.pathname);
这将删除 URL 参数。