Why does Firefox 5 ignore document.ready?

前端 未结 2 1415
借酒劲吻你
借酒劲吻你 2021-01-06 06:22

Why does Firefox 5.0.1 not refresh this page when the back button is pressed?



  

        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 06:23

    Why does Firefox 5.0.1 not refresh this page when the back button is pressed?

    Because it doesn't need to.

    When you go "back" in Firefox and Firefox can load the page entirely from the back button buffer, then what you are going back to is not to a fresh page but to the page in the exact state you left it before as if nothing had happened in between, and that includes the state of all your Javascript code and variables. As far as your script (and jQuery) is concerned, ready() has already fired. jQuery will not fire it a second time if it's already fired.

    What you probably want is to listen to the 'pageshow' event, which Firefox fires when the page is re-loaded from the buffer, even if its state is fully preserved.

提交回复
热议问题