Skip to content Skip to sidebar Skip to footer

Javascript: How Do I Change The Url In The Address Bar Without Refreshing The Page?

Possible Duplicate: How do I, with JavaScript, change the URL in the browser without loading the new page? I noticed that web apps like GMail and GrooveShark can change the URL

Solution 1:

Gmail and Grooveshark only change the hash, this is done by changing:

location.hash = 'blah'

If you target HTML5 enabled browsers, you can use window.history.pushState and window.history.popState, see http://spoiledmilk.dk/blog/html5-changing-the-browser-url-without-refreshing-page

Solution 2:

You may want to look into HTML5 push state. I know iQuery Mobile is using this feature to modify the location URL without triggering a page load and it might be the right solution for you.

https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

Here is an example of how it works:

window.history.pushState(data, "Title", "/new-url");

Post a Comment for "Javascript: How Do I Change The Url In The Address Bar Without Refreshing The Page?"