Created
August 29, 2021 19:36
-
-
Save procarrera/8caa0e8d6cb1e8ed7c911050a3008f35 to your computer and use it in GitHub Desktop.
Add Query String to URL and fire event every time it changes
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
// Add query string to URL | |
const newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?step=1'; | |
window.history.pushState({path:newurl},'',newurl); | |
// Fire event everytime state changes | |
window.addEventListener('popstate', function (event) { | |
console.log(event) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment