What I'm trying to achieve is to have this script run even after navigating back from #bar
to #foo
if ( window.location.href.indexOf('#') > -1 ) {
var url = window.location.hash.substr(1);
alert(url);
}
It is similar to this https://stackoverflow.com/questions/2638292/after-travelling-back-in-firefox-history-javascript-wont-run but the difference is that I will be navigating back to the same page but with diferent anchor.
Is this possible to achieve this with frameworkless javascript?
I saw Gmail have this router-like behavior with the use of anchor hash (if you browse through the mail), and that even when navigating back, the page responds.