onbeforeunload
- 关闭或刷新浏览器会触发此事件
window.onbeforeunload = function(ev) { ??????????return true;};
popstate
当点击浏览器后退按钮会触发此事件
基本上不用这个事件,vue 框架可以帮助代替这个事件
window.history.pushState("123", null, document.URL);window.addEventListener("popstate", function() { ???_this.isMsgShow = true; ???history.pushState("123", null, document.URL);});
JS——浏览器关闭事件
原文地址:https://www.cnblogs.com/cnloop/p/9347481.html