当前位置: 代码迷 >> JavaScript >> js窗口封锁事件
  详细解决方案

js窗口封锁事件

热度:69   发布时间:2012-10-24 14:15:58.0
js窗口关闭事件

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)这个判断条件表示窗口关闭。

  相关解决方案