JS:在没有特定参数的情况下重新加载页面

时间:2017-09-05 13:30:30

标签: javascript

我想在没有特定参数的情况下在Javascript中重新加载页面。

我们想要重新加载www.domain.com/abc?num=4&something=1

但我想重新加载www.domain.com/abc?number=4

不幸的是,以下内容保留了所有不适合我的用例的参数:

document.location.reload(false)

window.location.href = window.location.pathname;

删除每个参数,然后导航到路径。有没有办法在导航回到它之前从window.location删除查询参数?

1 个答案:

答案 0 :(得分:2)

location.href=location.href.replace(/&?somthing=([^&]$|[^&]*)/i, "");
相关问题