zoukankan      html  css  js  c++  java
  • 当页面返回不刷新时进行强制刷新

    disableBFCacheBeforeHistoryTravel: function() {
            // https://www.google.com/search?q=BFCache
            // 情景:将要跳转到某一被 BFCache 了的页面,希望该页面强制刷新
            // 用法:在 history.go() history.back() 之前调用此方法
    
            localStorage.setItem('bfcache_disable', true);
        },
        preventBFCacheOnCurrentPageBeforeHistoryTravel: function() {
            // https://www.google.com/search?q=BFCache
            // 情景:当前页面产生了 BFCache ,之后可能会再跳回来,此时会发生页面部分 js 没有执行,需要强制重新刷新的情况
            // 用法:在 location.href = 'xxx' / location.replace 之前 或 a.onclick 之时,调用此方法
    
            localStorage.removeItem('bfcache_disable');
            var timer;
            var stopLoop = function() {
                clearInterval(timer);
            };
            var loop = function() {
                if(localStorage.getItem('bfcache_disable')) {
                    localStorage.removeItem('bfcache_disable');
                    stopLoop();
                    location.reload();
                }
            };
            timer = setInterval(loop, 100);
            //auto stop after 5000 seconds
            setTimeout(stopLoop, 5000);
        }
    

      

  • 相关阅读:
    apache 错误日志
    搭建服务器
    vim配置
    临时表增加查询速度
    如何清空$_POST or $_GET
    hdu 2084
    快速幂
    zjut 1176
    rwkj 1091
    zjut 1090 --------同余定理的应用
  • 原文地址:https://www.cnblogs.com/lichuntian/p/6387504.html
Copyright © 2011-2022 走看看