浏览器关闭事件

关闭时的方法:
function window.onunload()
{
   alert("窗体关闭了!");
}

如果需要在关闭前给用户关闭提示,而且想在用户点击浏览器关闭按钮关闭时,也只有用以下的方法才能在退出时,执行事件:
function window.onbeforeunload()   
{   
    
if( event.clientX>document.body.clientWidth && event.clientY<0 || event.altKey )   
    
{   
        window.event.returnValue
="确定要退出本页吗?";   
    }

}
posted on 2007-01-10 11:11  网际浪人  阅读(4579)  评论(1编辑  收藏  举报