I have a page containing an iframe. An IFrame can accept user input (by pressing a button or selecting a menu) and display content accordingly. I need it, when the user manipulates the iframe, the browser pushes each set of iframe parameters into the story; and when the user clicks the back button, the iframe reloads its content using the saved parameters from the previous history entry. I have a piece of code performing a reboot as shown below.
It is strange when I make several settings in the iframe (therefore, several status records are added to the history), and then click on the back button, it will work as follows:
Say I have state 4, 3, 2 in history, and I'm now in state 5
- first click restore to state 4 (status message "---- state changed ----" printed
- a second click reloads the iframe with the default content. "---- state changed ----" is not printed; reboot code is not called.
- third click restore to state 3
- fourth click is like second click
- 5th click restore to state 2
So, after each click that successfully restores the state, it takes two clicks to fire the popstate event (I also tried to change the state with the same result) and restore it to another previous state.
Does anyone know what is going on here? Thanks in advance.
History.Adapter.bind(window, "popstate", function (event) { console.log("----state changed------", History.getState()); console.log("----state data------",History.getState().data.state);
source share