First of all I’m not interested of using some jquery plugin. I just want to know how did they achieve it so I can create a script like that.
On html5 history we use window.onpopstate event to detect back/forward browser event. What I want is to create something like this so I can use the hash type of url for other browser that doesn’t support html 5
something like this:
if(history.pushState){
//use html5 history event
window.onpopstate = function(event){that.__loadCurrentLink();};
}else{
//use the History event for other browser
window.historyEvent = function(event){that.__loadCurrentLink();};
}
Can you guys give some hint or anything so I will have the idea how to do this.
I’m just doing this for learning purposes and for the other people who want to know how to do this too. I hope some javascript monster can lead us the way.
Assign an event handler for the
hashchangeevent to window and use asetIntervalfor older browsers to pollwindow.location.hashevery 100ms etc, so when hashchange isn’t supported, you could get pretty much the up to date hash.I’d also suggest writing your links, buttons, etc to call the function that checks the hash on mouseup, so that you’d be guaranteed almost no delay when you click on a link that changes the hash.
Hashchange support in browsers: caniuse.com