在body中使用 onUnload="" 触发

<body onUnload="test();" ><script>
function test(){
    alert("我被触发了!  是在关闭窗口的时候");
}
</script>

解决方案 »

  1.   

    <body onBeforeUnload="alert('close')"></body>
      

  2.   

    <script>
    function a()
    {
    if(event.clientY<0 && event.clientX>document.body.clientWidth){                   
           alert("是窗口关闭");
             }
        else{
           alert("是刷新");
       }
    }
    </script>
    <body onbeforeunload="a()">
      

  3.   

    <body onbeforeunload="return 'ok??'>"
      

  4.   

    <body onbeforeunload="return 'ok??'">
      

  5.   

    net_lover(孟子E章)   谢啦!!
      

  6.   

    呵呵  net_lover(孟子E章)  牛!...