cnloop

onbeforeunload

  • 关闭或刷新浏览器会触发此事件

  • 示例代码

    window.onbeforeunload = function(ev) {       
        return true;
    };
    

popstate

  • 示例代码

    window.history.pushState("123", null, document.URL);
    window.addEventListener("popstate", function() {
        _this.isMsgShow = true;
        history.pushState("123", null, document.URL);
    });
    
  • 当点击浏览器前进或者后退按钮会触发此事件

  • 基本上不用这个事件,vue 框架可以帮助代替这个事件

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-12-06
  • 2021-12-23
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案