在开发中经常会遇到在一个页面操作完返回上一个页面,此时要求上个页面展示最新数据的需求。

比如 A1为上一个页面,A2为当前页面

 

1.A1需要加监听历史记录点

 window.onpopstate=function(){
    // 获得存储在该历史记录点的json对象
    var  json=window.history.state;// 获得的json为null时则无需刷新
    if(json){
        window.location.reload();
    }
};   

 

2.跳转A2前需要先替换当前历史记录点

var  json={time:new Date().getTime()};
window.history.replaceState(json,"",window.location.href+"&t="+new Date().getTime());
window.location.href= A2;

广州vi设计公司 http://www.maiqicn.com 我的007办公资源网 https://www.wode007.com

3.A2返回A1

window.history.back();

相关文章:

  • 2021-09-26
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案