window.onbeforeunload=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)这个判断条件表示窗口关闭。
本文介绍了一个JavaScript窗口关闭事件(onbeforeunload)的实现方法,并提供了一种判断页面是刷新还是关闭的技术方案。
224

被折叠的 条评论
为什么被折叠?



