简体   繁体   English

JavaScript-从地址栏中的URL删除所有获取参数,而无需重新加载页面

[英]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.

相关问题 JavaScript 使用新 URL 更改地址栏而无需重新加载页面 - JavaScript change address bar with new URL without reloading the page 如何在不重新加载页面的情况下更改地址栏中的URL? - How do you change the URL in the address bar without reloading the page? 如何在不重新加载页面的情况下将浏览器地址栏中的 URL 更改为 angularJS - How to change URL in browser address bar with angularJS without reloading the page 如何在不重新加载页面的情况下打开新标签并使用新URL更新地址栏 - How to open a new tab and update address bar with new URL without reloading the page 更改地址 URL 全部在“domain.com/”之后,无需重新加载页面 - Changins Address URL All Afer "domain.com/" Without Reloading Page 当页面加载失败时,我可以从javascript控制台获取地址栏网址吗? - Can I get the address bar url from the javascript console when the page has failed to load? 从数据库删除数据而无需重新加载页面 - Delete data from database without reloading the page 链接从url中删除`#`而不重新加载页面 - link to remove `#` from url without reloading the page 发送GET变量而无需使用javascript重新加载页面 - Send GET variables without reloading the page with javascript 更改地址栏中的完整URL,而无需重新加载页面 - Change complete URL in adress bar, without reloading the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM