onhashchange Event in JavaScript
onhashchange Event in JavaScript
The onhashchange event fires when there have been changes to the anchor part of the current URL. For invoking this event, we have to change the anchor part by location.hash or location.href. It only works on the body element.
Syntax:-
Its syntax is:- < anyElement onhashchange="my_script" > OR object.onhashchange= function(){my_script} OR object.addEventListener("hashchange", my_script)