关闭网页时如何弹出消息框 提醒用户:您确认关闭吗 ?

解决方案 »

  1.   

    <BODY onbeforeunload="event.returnValue='您确认关闭吗';"></BODY>
      

  2.   

    <body onunload="return confirm('要离开吗?')">
      

  3.   


      <script type="text/javascript">
        function   closeIt()   
      {   
      if(event.clientX > document.body.clientWidth && event.clientY<0||event.altKey)   
      {   
      //window.event.returnValue="确定要退出本页吗?";   
      alert('我要退出啦!')   
      //document.frames.exitframes.location.reload("exit.aspx?id=2");     
      }   
      else   
      {   
      return   false;   
      }   
      }   
        </script></head>
    <body onunload="closeIt()">
        <form id="form1" runat="server">
            <div>
            </div>
        </form>
    </body>
      

  4.   


    <body onbeforeunload="RunOnBeforeUnload();"  function RunOnBeforeUnload() {
                 if (true) {window.event.returnValue = '如果是,你将丢失没有保存的内容。';   
                 }  
              }
      

  5.   

    <input type="button" value="取消" onclick="window.close()"/>当前窗口关闭
      

  6.   


    <body onunload="return confirm('Leave?')"> 
    Up