Internet Explorer 11 Back Button Javascript Behavior

后端 未结 5 1325
别跟我提以往
别跟我提以往 2020-12-11 01:37

In Chrome, FF, and IE8-10, when I press the back button, my javascript $(document).ready() function is called, but in IE11, none of the javascript is invoked. Does anyone kn

5条回答
  •  感情败类
    2020-12-11 01:57

    I also have encountered this issue, which is clearly not a bug if you read IE Doc. As wrote Robert Daly, take a look to http://msdn.microsoft.com/library/ie/dn265017(v=vs.85).aspx You can find on this doc that beforeunload event prevents BF cache. So here is a short peace of code that defines this event writing on the console to prevent BF cache:

    if (typeof window.onbeforeunload != 'undefined'){
       function doNothing(){
          console.log('Prevent BF Cache');
       }
       window.onbeforeunload = doNothing;
    }
    

提交回复
热议问题