<script language=javascript>
function window.onbeforeunload()
{
if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey){
  window.event.returnValue="确定要退出本页吗?";}
}
</script>

解决方案 »

  1.   

    <body Onunload="return confirm('exit?');">
      

  2.   

    <body onbeforeunload="event.returnValue='真的要走?'">
    ...
    </body>
      

  3.   

    这样写刷新的时候也回弹出msg,如何在刷新的时候做到不弹出msg?
    再次请教各位!
      

  4.   

    按右上角的×按钮可以弹msg了,刷新也没问题。
    可是按画面中的关闭按钮(onclick="window.close();")却不弹msg。
      

  5.   

    <script language=javascript>
    function quit()
    {
    if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey){
      window.event.returnValue="确定要退出本页吗?";}
    }
    </script>
    onclick="javascript:quit();window.close();")
      

  6.   

    <script language=JavaScript>
    function window::onbeforeunload(){
    if (event.clientY<0 && event.clientX>document.body.clientWidth-20
    || event.clientY<0 && event.clientX<20
    || event.altKey 
    || event.clientY>document.body.clientHeight)
    event.returnValue="真的要走?"
    }
    </script>
    <button onclick="if (confirm('真的要走?')) window.close()">关闭</button>
      

  7.   

    设置flag全局变量,所有链接到其他页面的动作前(即离开当前页面),设置flag变量为0,则正常连接不会弹出确认对话框 
    <html> 
    <head> 
    <script language="JavaScript"> 
    <!-- 
    var flag = 0;//Prompt for quitting 
    function leaveAlert() 

    if ( flag == 1 ) 
    return 'Are you sure to Leave Current Window?'; 

    //--> 
    </script> 
    </head> 
    <body onbeforeunload="return leaveAlert();">  
    <a href="about:blank" onclick="flag=0;">Leave Without Prompt 
    <br> 
    <a href="about:blank" onclick="flag=1;">Leave With Prompt 
    </body> 
    </html>
      

  8.   

    <script language=JavaScript>
    function window::onbeforeunload(){
    if (event.clientY<0 && event.clientX>document.body.clientWidth-20
    || event.clientY<0 && event.clientX<20
    || event.altKey 
    || event.clientY>document.body.clientHeight)
    event.returnValue="真的要走?"
    }
    </script>
    <button onclick="if (confirm('真的要走?')) window.close()">关闭</button>
      

  9.   

    不错.—————————————————————————————————
    ┏━★━━◆━━★━┓ 
    ♂欢|◢CSDN◣|使♂        ▲自由保存帖子,浏览,关注检测
    ┃迎|◥论坛助手◤|用┃        ▲完善的CSDN客户端工具
    ┗━☆━━◇━━━☆┛       ▲自动添加签名......让你更快,更爽,更方便地上CSDN...
    http://www.csdn.net/expert/topic/573/573604.xml
    http://www.chinaok.net/csdn/csdn.zip