监听页面回退

 if (window.history && window.history.pushState) {
      history.pushState(null, null, document.URL);
      setTimeout(() => {
        window.addEventListener("popstate", myfuntion, false); //false阻止默认事件
//myfunction 页面回退前执行的函数
        //监听页面回退
      }, 0);
    }
posted @ 2020-09-08 17:20  Sonya·Lv  阅读(486)  评论(0编辑  收藏  举报