加入以下代码:

引用内容:
window.addEventListener('pageshow', function (event) {
if(event.persisted || window.performance && window.performance.navigation.type == 2){
console.log('window.performance.navigation.type: '+ window.performance.navigation.type)
// location.refresh(); //此处可以写你的实际应用的代码
location.reload();
}
},false);


也可禁止缓存,重新进入页面

引用内容:
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">




返回上一页代码:

引用内容:
<a href="Javascript:window.history.go(-1)">返回上一页</a> 
 
 
 
 
解释:

window.performance 是W3C性能小组引入的新的API,目前IE9以上的浏览器都支持。

window.performance.navigation.type包含三个值:
0 : TYPE_NAVIGATE (用户通过常规导航方式访问页面,比如点一个链接,或者一般的get方式)

1 : TYPE_RELOAD (用户通过刷新,包括JS调用刷新接口等方式访问页面)

2 : TYPE_BACK_FORWARD (用户通过后退按钮访问本页面)

相关文章:

  • 2021-05-17
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案