原生方法:
window.onunload = window.onbeforeunload = function(){
  alert("aaa");
};
jquery方法:
$(window).on("unload  beforeunload", function(){
  alert("aaa");
});
尝试只使用onunload、unload,不生效。
jquery api文档中查不到beforeunload事件,但是却起作用了。

相关文章:

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