Internet Explorer 11 Back Button Javascript Behavior

后端 未结 5 1332
别跟我提以往
别跟我提以往 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:46

    you can use window.onhashchange to monitor behaviors of the back/forward buttons.

    var isInited = false;
    
    function init() {
        if (isInited) {
            return;
        }
        isInited = true;
    
        ...
    }
    
    $(document).ready(init);
    
    window.onhashchange = function() {
        $(document).ready(init);
    };
    

提交回复
热议问题