listen to hashchange javascript code example
Example: javascript detect URL hash change
window.addEventListener("onhashchange", function(){
//url hash # has changed
});
window.addEventListener("onhashchange", function(){
//url hash # has changed
});