Created
October 10, 2016 17:50
-
-
Save pimterry/260841c2104f27cadc954a29b9873b96 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) { | |
event.preventDefault(); | |
history.pushState({}, "", link.href); | |
// Update the URL again with the same hash, then go back | |
history.pushState({}, "", link.href); | |
history.back(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment