昨天问了这个问题,但是后来试了下,用onbeforeunload并不行。
因为用onbeforeunload的话,刷新这个页面,也有同样的提示框弹出。
请哪位高手再教我下,怎么让关闭这个网页的时候,弹出个提示窗口啊?谢谢了。

解决方案 »

  1.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function window.onbeforeunload()
       {
       if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
       {
       window.event.returnValue="确定要关闭此页吗?";
       }else
       {
            ////刷新进入这里
       }
    }
    //-->
    </SCRIPT>
    上面的代码不行吗?
    如果不可以的话,浏览http://www.cssrain.cn/article.asp?id=681
      

  2.   

    <html>
    <script>
    function logout()
    {
    if (confirm('是否退出?...'))
        {
         return true;
        }
         else
        {
         return false;
        }
      }
    </script> <head><title>index</title></head>
    <body  onbeforeunload="return logout()">
    </body>
    </html>
      

  3.   

    刚才看错了......
    你看下下面的,再自己改成你要的吧.<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>只在关闭窗口的时候提示,刷新的时候不提示</title>
    <script for=window event=onbeforeunload>
    if(event.clientX>document.body.clientWidth)
    {
    if (confirm('是否退出?...'))
        {
            return true;
        }
         else
        {
            return false;
        } }
    </script>
    </head><body></body></html>
      

  4.   

    如果把那个JAVASCRIPT改成下面的就只有一个提示框了:
    <script for=window event=onbeforeunload>
        if(event.clientX>document.body.clientWidth)
        {
    window.event.returnValue = '不保存数据了吗?';
        }
    </script>