Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nikitekirsha/0a8d689b8ac6483ec3522f7a7c60fc63 to your computer and use it in GitHub Desktop.
Save nikitekirsha/0a8d689b8ac6483ec3522f7a7c60fc63 to your computer and use it in GitHub Desktop.
hash remover
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