//Original address abc.com/sss.html //abc.com/sss.html#dsf window.location.hash = "dsf"; //abc.com/my/awesome/url var stateObject = {}; var title = "Wow Title"; var newUrl = "/my/awesome/url"; history.pushState(stateObject,title,newUrl);
Listening to the hash value is: # The following value changes
window.onhashchange = function(){ alert(window.location.hash); };
** Override the history.pushState method
history.pushState = function(){ alert("sdf"); }
** A complete instance of executing the method according to the hash change
if(window.location.hash != ""){ window.location.hash = ""; } window.onhashchange = function(){ if((window.location.hash).indexOf("show") > -1){ coverShow(); }else{ coverHide(); } }; $('.top_bar .menu').tap(function(){ if((window.location.hash).indexOf("show") > -1){ window.location.hash = ""; }else{ window.location.hash = "show"; } }); function coverShow(){ } function coverHide(){ }