Reputation: 20362
Is it possible to clear all GET parameters from the URL in the browsers address bar without initiating a page reload?
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.
window.location.href = window.location.href.replace(window.location.search,'');
window.stop();
document.execCommand('Stop');
Upvotes: 0
Views: 2215
Reputation: 146
get the base url without parameters
baseUrl = window.location.href.split("?")[0];
then setting the url inside the address bar
window.history.pushState('name', '', baseUrl);
Upvotes: 3