In older browsers, you can not change the URL in the address bar without leaving the page. But you can change the hash of the URL without leaving the page. That is, you can change www.example.com to www.example.com#new_text using JavaScript window.location.hash = "new_text" ; everything after # can be changed.
However, HTML5 has a new history API that allows you to change the portion of the URL after the domain. Thus, you still cannot change www.example.com to www.BankOfAmerica.com (for security reasons), but you can change www.example.com/foo to www.example.com/bar .
history.pushState("object or string representing the state of the page", "new title", "newURL");
Check When can I use ... to see which browsers support HTML5 session history management and support the new pushState method.
In addition, there is a JavaScript library that normalizes the history API in browsers and changes the URL in new browsers and uses the hash part for older browsers. See history.js .
Adam Nov 03 '10 at 16:25 2010-11-03 16:25
source share