Created
October 10, 2016 17:22
-
-
Save pimterry/6ee334774245c74493d2729b4fd7f59f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hashLinks = document.querySelectorAll("a[href^='#']"); | |
[].forEach.call(hashLinks, function (link) { | |
link.addEventListener("click", function (event) { | |
// Disable jumping around and URL updates | |
event.preventDefault(); | |
// Update the URL only ourselves | |
history.pushState({}, "", link.href); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment