Clicking on a link to a local anchor can be detected via window.onhashchange()
if it involves a change to the URL hash.
However, I notice at least in Chrome (I have not checked this with other browsers), if you then scroll around the page and select a link to the same local anchor again, any onclick
handler for the link fires, then the page jumps to to the anchor, but obviously onhashchange()
does not fire, and neither does window.onload()
. The reason this is significant is both of these would fire after the move to the anchor, whereas the link onclick
handler fires before.
So: Is there a correlate to onload()
for jumping to a local anchor that is already indicated in the URL hash?