I am using Ajax and hash for navigation.
Is there a way to check if the window.location.hash
changed like this?
http://example.com/blah
I was using this in a react application to make the URL display different parameters depending what view the user was on.
I watched the hash parameter using
window.addEventListener('hashchange', doSomethingWithChangeFunction());
Then
doSomethingWithChangeFunction () {
// Get new hash value
let urlParam = window.location.hash;
// Do something with new hash value
};
Worked a treat, works with forward and back browser buttons and also in browser history.