I have a page divided into various divs, each with an unique id.

The user can navigate through these divs using a nav bar at the top of the screen, which is pinned in position with 'position:fixed'.

I want to fire a JavaScript event whenever the user views a different div.

I have attached an event handler to the links in the nav bar. Correspondingly when the user uses the nav bar to move around the page the desired event always fires.

However, if the user uses the address bar to navigate nothing happens, e.g. if someone is viewing "www.mysite.com/#panel1" and then types into the address bar "www.mysite.com/#panel2", they are moved to the corresponding section of the site, but no event fires.

Is there any way to achieve this?

Thanks in advance.