我需要logout function
在浏览器窗口关闭时调用。它在 Chrome 中运行良好,在 IE 和 Safari 中无法运行。
我尝试了以下代码:
window.onbeforeunload = function (e) {
// Your logic to prepare for 'Stay on this Page' goes here
var evtobj = window.event ? event : e;
if (evtobj == e) {
//firefox
if (!evtobj.clientY) {
//server call
}
}
else {
//IE
if (evtobj.clientY < 0) {
//server call
}
}
//return "Please click 'Stay on this Page' and we will give you candy";
};
我尝试了其他一些方法,但没有奏效。请指教。