window.onbeforeunload = function (e) { e = e || window.event; var y = window.event.clientY;//e.clientY:只有IE8支持 if (y <= 0//点击浏览器或者选项卡的关闭按钮 || y >= Math.max(document.body ? document.body.clientHeight : 0, document.documentElement ?document.documentElement.clientHeight : 0)//点击任务栏的关闭按钮 ) { //浏览器关闭之前执行的操作 $.ajax({ type: "POST", url: "<%=path%>/pages/common/logoutForWebClose.action", dataType: "text", async: false, success: function(data){ alert("closeSuccess"); } }); }}