The idea is to start an animation when a given hash is found in the URL.
Example
Taking the example of a page whose navigation works by hash:
<nav>
<ul>
<li><a href="#john">John</a></li>
<li><a href="#doe">Doe</a></li>
<li><a href="#Jane">Jane</a></li>
</ul>
</nav>
<section id="john">Super BuBu</section>
<section id="doe">Super Saiyan</section>
<section id="jane">Jane Porter</section>
The user clicks the menu and the page scrolls to the id
in question.
The idea is to trigger an action when for example accessing the #doe
that could be performed through the click event on the link with href
equal to #doe
.
Problem
If the user directly accesses the page through a URL that already contains the hash to direct it to the correct section, the action previously associated with clicking on the referenced element is not triggered.
http://www.meusite.com/bananas.php#doe
Question
How do I trigger an action when a hash is found in the browser URL?