0

I have a problem with window.onhashchange and the back button in Firefox 21.

I coded a test page where a hash is added to the address when the user selects an element on the page:

ELEMENT.onclick > window.location.hash = ID

where ID is the element's id.

With

window.onhashchange = hashChanged

I bind the hashchange event to a function where I select the element identified by the hash.

As long as I stay on my test page it works fine. I can go back and forward in the browser history by pressing the back and forward button, and the hashchange event is fired, i.e. the state of my page is changed accordingly.

However, when I browse to another page in the tab where I have used my test page and then press the back button to return to my page, it is in the initial state. The right hash is in the address bar, as expected, but the hashchange event is not fired.

What is the problem?

4

0 回答 0