手机端返回上一页HTML,解决移动端,返回上一页面,刷新问题 |
您所在的位置:网站首页 › html自动返回上一页 › 手机端返回上一页HTML,解决移动端,返回上一页面,刷新问题 |
通常可以用到window.history.back(); window.history.go(-1);返回刷新上一页, 但当两种方法都不满足你的开发需求的时候,可以采用以下的方法。 从a页面,跳转到b页面,b页面的数据操作,会影响a页面的展示。那么在b页面里就可以使用,sessionStorage.setItem("need-refresh", true); 然后再进行window.history.go(-1)操作。 // a.html 设置刷新 检测缓存是否有标志 要是有就说明数据有变化 a.html跳转到b.html页面 window.addEventListener("pageshow", function(){ if(sessionStorage.getItem("need-refresh")){ location.reload(); sessionStorage.removeItem("need-refresh"); } }); // b.html 如果是数据变化了就写一条缓存 b.html返回到a.html页面 sessionStorage.setItem("need-refresh", true); |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |