ios点击微信浏览器的返回按钮js不执行问题

214 阅读1分钟

思路:

1、添加头部信息,设置不缓存

2、ios页面reload

解决方案

 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-Control" content="no-cache,must-revalidate">
 <meta http-equiv="wxpires" content="0">
  var browserRule = /^.*((iPhone)|(iPad)|(Safari))+.*$/;
    if (browserRule.test(navigator.userAgent)) {
      window.onpageshow = function(e){
        if(e.persisted){
          window.location.reload(true)
        }
      }
    }