有没有什么办法可以检测到整个浏览器关闭,然后在关闭之前调用一个函数?这是专门针对Google Chrome的。本质上,我需要在用户关闭之前提醒用户。这将是一个铬扩展。Chrome扩展在浏览器关闭之前做些什么
我已经试过
window.onbeforeunload = function() {
alert("can't exit yet");
return null;
}
和
window.addEventListener("beforeunload", function (e) {
alert("can't exit yet");
return null;
});
他们都无能为力。 Chrome仍然退出并且不会提醒。
非常感谢您的帮助!基于该documentation of on the onbeforeunload
event handler
[Event onBrowserClose for Google Chrome?](http://stackoverflow.com/questions/3390470/event-onbrowserclose-for-google-chrome) –