window.οnbefοreunlοad=function window.onbeforeunload(){
if (event.clientX>document.body.clientWidth && event.clientY<0 ||event.altKey){
alert(111);
}else{
window.event.returnValue="";
return false;
}
}
js窗口关闭事件使用onbeforeunload_handler() 。该方法是在页面刷新或者重新加载时被调用。如何判断该页面是刷新还是关闭,使用如下判断即可if (event.clientX>document.body.clientWidth && event.clientY<0 ||event.altKey)这个判断条件表示窗口关闭。