我正在使用以下代码,它在 Internet Explorer 中运行良好,但在 Firefox 中无法运行。
当用户关闭浏览器时,必须调用一个 web 方法来更新IsLogin=false
数据库中的位字段。
window.onbeforeunload = function (e) {
var evt = window.event || e;
var y = evt.clientY || evt.pageY;
if (y < 0 || evt.clientX<0) {
$.ajax({
type: "POST",
url: "/Application/WebForm1.aspx/Update",
async: false,
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert('Sucessfull Call');
}
});
}
}