MooTools onHashChange Event
This is a simple script to add the onhashchange event to browsers that don't already support it.
Internet Explorer 8 and Firefox 3.6 have the 'onhashchange' event introduced.
Element.Events.hashchange = {
onAdd: function(){
var hash = self.location.hash;
var hashchange = function(){
if (hash == self.location.hash) return;
else hash = self.location.hash;
var value = (hash.indexOf('#') == 0 ? hash.substr(1) : hash);
window.fireEvent('hashchange', value);
document.fireEvent('hashchange', value);
};
if ('onhashchange' in window){
window.onhashchange = hashchange;
} else {
hashchange.periodical(50);
}
}
};
window.addEvent('hashchange', function () { // do stuff });
https://github.com/mootools/mootools-core/blob/master/Source/Element/Element.Event.js#L141
hashchange: 1, popstate: 2, // history