<body onbeforeunload="event.returnValue='';" onunload="alert('欢迎下次再来!');">

解决方案 »

  1.   

    楼上的好象不能刷新哎
    这个问题其实是接着以前我的一篇“怎样实现关闭IE后自动logout”的,现代码列如下:
    <html>
    <head>
    <script language=javascript>
    window.onbeforeunload = function()
    {
      if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
      {
     
    var x=confirm ("确定要退出吗?");
    if (x)
       // 这里执行 logout()
    alert ("Log out!");
    else
    return false;
      }
    }
    </script></head>
    <body>
    测试关闭IE自动LOGOUT的页面。
    </body>
    </html>这时刷新不会有什么问题,当关闭IE时,若选择确定则一切正常,若选择取消后,在再次弹出的对话框中若再选择离开(关闭IE),怎样还能实现alert(即我的logout函数)??