I need to detect some event in which an URL navigates to an anchor:
<a name="latest-topics"></a>
http://someserver.com/index.html#latest-topics
And then I would like to use some event of the kind of onfocus
, onclick
, etc.
<a onclick="doSomething()" onfocus="doSomething()" name="latest-topics"></a>
What options are there to detect navigating to such anchor in the precise event of navigating to it?
Or would I need a timer with setInterval
to continuously poll changes to location.hash
every few milliseconds?