How do I modify the URL without reloading the page?

Posted by Editorial Staff | Updated on

Want to modify the URL without reloading the page? This can now be done in Chrome, Safari, Firefox 4+, and Internet Explorer 10pp4+!

Updating address bar with new URL without hash or reloading the page.

You can then use window.onpopstate to detect the back/forward button navigation:

window.onpopstate = function(e){
if(e.state){
document.getElementById(“content”).innerHTML = e.state.html;
document.title = e.state.pageTitle;
}
};


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers