我正在尝试使用javascript检查浏览器选项卡是否关闭。为此,请使用下面的代码,该代码是在这里source link找到解决方案的结果 问题是该代码和其他一些代码解决方案不再适用于chrome,firefox,safari浏览器。请更新...
window.onbeforeunload = function (event) {
var message = 'Important: Please click on \'Save\' button to leave this page.';
if (typeof event == 'undefined') {
event = window.event;
}
if (event) {
event.returnValue = message;
}
return message;
};
$(function () {
$("a").not('#lnkLogOut').click(function () {
window.onbeforeunload = null;
});
$(".btn").click(function () {
window.onbeforeunload = null;
});
});