Created
March 21, 2020 01:06
-
-
Save nikitekirsha/0a8d689b8ac6483ec3522f7a7c60fc63 to your computer and use it in GitHub Desktop.
hash remover
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
function removeLocationHash() { | |
var noHashURL = window.location.href.replace(/#.*$/, ''); | |
window.history.replaceState('', document.title, noHashURL); | |
}; | |
window.addEventListener("popstate", function (event) { | |
removeLocationHash(); | |
}); | |
window.addEventListener("hashchange", function (event) { | |
event.preventDefault(); | |
removeLocationHash(); | |
}); | |
window.addEventListener("load", function () { | |
removeLocationHash(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment