Created
March 26, 2010 22:35
-
-
Save clehner/345486 to your computer and use it in GitHub Desktop.
Simulate 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
// Simulate onhashchange support in all browsers | |
"onhashchange" in window || (function () { | |
var lastHash = ''; | |
function pollHash() { | |
if (lastHash !== location.hash) { | |
lastHash = location.hash; | |
var event = document.createEvent("HTMLEvents"); | |
event.initEvent("hashchange", true, false); | |
document.body.dispatchEvent(event); | |
if (typeof onhashchange == "function") { | |
onhashchange(event); | |
} | |
} | |
} | |
setInterval(pollHash, 100); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment