Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created March 20, 2010 16:45
Show Gist options
  • Save cowboy/338759 to your computer and use it in GitHub Desktop.
Save cowboy/338759 to your computer and use it in GitHub Desktop.
Damn browser crash...
(function($){
var supports_onhashchange = 'onhashchange' in window,
last_hash = location.hash,
timeout_id;
$.event.special.hashchange = {
setup: function() {
if ( supports_onhashchange ) { return false; }
start();
},
teardown: function() {
if ( supports_onhashchange ) { return false; }
stop();
}
};
function start() {
var hash = location.hash;
if ( hash !== last_hash ) {
$(window).trigger( 'hashchange' );
last_hash = hash;
}
timeout_id = setInterval( start, 100 );
};
function stop() {
clearTimeout( timeout_id );
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment