[英]JavaScript - delete all get parameters from URL in address bar without reloading the page
Is it possible to clear all GET parameters from the URL in the browsers address bar without initiating a page reload? 是否可以在不启动页面重新加载的情况下从浏览器地址栏中的URL清除所有GET参数?
I tried to remove all GET prematers and then fake a page reload and immediatelly interrupt it as a workaround, but this does not replace the URL. 我试图删除所有GET premater,然后伪造页面重新加载并立即将其中断作为解决方法,但这不能替代URL。
window.location.href = window.location.href.replace(window.location.search,'');
window.stop();
document.execCommand('Stop');
get the base url without parameters 获取不带参数的基本URL
baseUrl = window.location.href.split("?")[0];
then setting the url inside the address bar 然后在地址栏中设置网址
window.history.pushState('name', '', baseUrl);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.