Created
May 22, 2018 06:34
-
-
Save McKabue/724f347af51feaa9a9454a89eb7f5ad8 to your computer and use it in GitHub Desktop.
This little gem ensures a consistent update of the browser history (both url and title) in an Single Page Application in a conventional manner
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
if ('history' in window) { | |
window.history.__pushState = window.history.pushState; | |
window.history.pushState = function (_data, _title, _url) { | |
window.history.__pushState(null, null, _url); | |
window.document.title = _title; | |
}; | |
window.history.__replaceState = window.history.replaceState; | |
window.history.replaceState = function (_data, _title, _url) { | |
window.history.__replaceState(null, null, _url); | |
window.document.title = _title; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment