Created
January 12, 2012 10:27
-
-
Save Integralist/1599740 to your computer and use it in GitHub Desktop.
Detect `onhashchange` support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var docmode = document.documentMode; | |
// Does the browser support window.onhashchange? | |
// Note that IE8 running in IE7 compatibility mode reports true for 'onhashchange' in window, | |
// even though the event isn't supported, so also test document.documentMode. | |
if ('onhashchange' in window && (docmode === undefined || docmode > 7 )) { | |
window.onhashchange = checkHash; | |
} | |
// IE7 doesn't support the hashchange event so we fall back to standard polling technique | |
else { | |
poll = window.setInterval(checkHash, 500); | |
// Clean-up objects as IE7 has hideous performance | |
window.onunload = function() { | |
window.clearInterval(poll); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment