点击回退按钮刷新页面

浏览器用户返回上一步,自动刷新
window.onunload=function(){} 这个最简单粗暴

方式一、
<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()
}
};
}
ps:在ios可能出现未知错误,在使用微信支付时页面偶现卡死现象

方式二、
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() }};
方式四、直接在进行页面跳转的时候使用window.location.replace()跳转,直接就没有了回退问题了

拿来试了下,第一个方法较好,第二个会有一些兼容性问题,效果不是很好

转载于:https://blog.51cto.com/13845970/2152485

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值