Is there a cross-browser onload event when clicking the back button?

后端 未结 15 2703
被撕碎了的回忆
被撕碎了的回忆 2020-11-21 22:46

For all major browsers (except IE), the JavaScript onload event doesn’t fire when the page loads as a result of a back button operation — it only fires when the

15条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-21 23:29

    OK, I tried this and it works in Firefox 3, Safari 3.1.1, and IE7 but not in Opera 9.52.
    If you use the example shown below (based on palehorse's example), you get an alert box pop-up when the page first loads. But if you then go to another URL, and then hit the Back button to go back to this page, you don't get an alert box pop-up in Opera (but you do in the other browsers).

    Anyway, I think this is close enough for now. Thanks everyone!

    
    
    
    
    Untitled Document
    
    
    
    
    
    

    Test of the page load event and the Back button using jQuery

提交回复
热议问题