Reputation: 404
Is it possible to rewrite a pages URL without having the page reload it self via Javascript when setting the window.location to slash?
For example, I have an a href item that sets the link to #item1
<a href="#item1">
and then it's linked up via to a js class that pulls a popup open and when the popups close button is pressed I then rewrite the url to
window.location = "/#";
Is it possible to rewrite the url to so that there is no hash remaining?
window.location = "/";
Without having the webpage reload it self since / means home?
Upvotes: 1
Views: 1991
Reputation: 1106
var stateObj = { home: "home" };
history.pushState(stateObj, "home", "/");
Upvotes: 1
Reputation: 9301
You should check out the History API.
http://diveintohtml5.info/history.html
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history
Upvotes: 2