Skip to content

Instantly share code, notes, and snippets.

@ilhamgusti
Created August 2, 2022 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilhamgusti/6f443f40880ca0a5c6f5d3aac5859ec3 to your computer and use it in GitHub Desktop.
Save ilhamgusti/6f443f40880ca0a5c6f5d3aac5859ec3 to your computer and use it in GitHub Desktop.
subscribing hash change
if ("onhashchange" in window) {
window.onhashchange = function () {
alert(window.location.hash);
}
}
else {
var prevHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != prevHash) {
prevHash = window.location.hash;
alert(window.location.hash);
}
}, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment