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