Reputation: 1295
I have seen posts on here to remove the hash value from a url... but how do remove the value and the # itself.
for example if a url was
mysite.com
and when a user navigates through the one page application the url might change to
mysite.com#mytest
so when they reload it i just want it to show
mysite.com and not mysite.com#mytest
these two just remove the value
location.hash = 'home';
window.location.replace("#");
thanks
Upvotes: 0
Views: 59
Reputation: 1204
var href = window.location.href;
var index = href.indexOf('#');
if ( index > 0) {
window.location = href.substring(0, index);
}
Upvotes: 1
Reputation: 2021
I don't think it's possible to remove the hash without reloading the page.
Upvotes: 1