Updating address bar with new URL without hash or reloading the page example:
1 2 3 4 5 6 7 8 |
function processAjaxData(response, urlPath) { document.getElementById("content").innerHTML = response.html; document.title = response.pageTitle; window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath); } |
You can then use window.onpopstate
to detect the back/forward button navigation:
1 2 3 4 5 6 7 8 9 10 |
window.onpopstate = function(e) { if(e.state) { document.getElementById("content").innerHTML = e.state.html; document.title = e.state.pageTitle; } }; |