点击回退按钮刷新页面

来源:互联网 发布:沃尔玛库存优化管理 编辑:程序博客网 时间:2024/05/18 07:53
浏览器用户返回上一步,自动刷新方式一、<input type="hidden" id="refreshed" value="no"><script type="text/javascript">onload=function(){var e=document.getElementById("refreshed");if(e.value=="no")e.value="yes";else{e.value="no";location.reload();}}
//ios 由于其回退的机制问题导致js不会去执行,得添加如下写法
var browserRule = /^.*((iPhone)|(iPad)|(Safari))+.*$/;if (browserRule.test(navigator.userAgent)) {    window.onpageshow = function(event) {        if (event.persisted) {            window.location.reload()        }    };}
</script >方式二、header("Cache-Control: no-store, must-revalidate, max-age=0");header("Pragma: no-cache");header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");方式三、window.onpageshow = function(event) {if (event.0) { window.location.reload() }};
拿来试了下,第一个方法较好,第二个会有一些兼容性问题,效果不是很好
原创粉丝点击