首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js窗口封锁事件

2012-10-24 
js窗口关闭事件window.onbeforeunloadfunction window.onbeforeunload(){????if (event.clientXdocument

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

热点排行
Bad Request.