<body onunload="alert('你正在关闭浏览器')">

解决方案 »

  1.   

    BrentIvan老兄,
    用onunload的话,点refresh也会弹出警告窗口,所以这不是我想要的结果。
    我的意思就是在close事件发生之前想处理一些事情,怎样铺捉到浏览器的关闭事件。
      

  2.   

    是这样吗。
    <html>
    <head>
    <script language="JavaScript"><!--
    function unload() {
         if (confirm("Do ya really wanna go?"))
    }
    //--></script></head><body onUnload="unload()">
    ...
    </body>
    </html>
      

  3.   

    <script language="javascript">
    <!--
    function window_onunload() {
       //执行删除机器文件操作,呵呵
       alert("您正在关闭窗口!");
    }
    -->
    </script>
      

  4.   

    <html>
    <head>
    <script language="JavaScript"><!--
    function confirmIEleave() {
        event.returnValue = "Are you sure you want to leave this page?";
    }function confirmNSLeave(iWindow) {
        if (!document.layers) return;
        if (!iWindow.closed) {
            if (!confirm('Are you sure you want to leave this page?'))
                window.location.href = 'javascript:void(0)';
       }
    }
    //--></script>
    </head><body onbeforeunload="confirmIELeave()" onUnload="confirmNSLeave()"><p>
    Navigate to another page to fire the before unload event.
    </p></body>
    </html>
      

  5.   

    路人甲,把你的代码粘了一下,可是效果没出来,why?
    海盗,怎样激活你的window_onunload()函数?