久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript如何捕獲窗口關閉事件

      javascript捕獲窗口關閉事件的方法:1、用javascript重新定義【window.onbeforeunload()】事件;2、在body標簽里加入onUnload事件。

      javascript如何捕獲窗口關閉事件

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版,DELL G3電腦。

      javascript捕獲窗口關閉事件的方法:

      1.用javascript重新定義 window.onbeforeunload() 事件

      在javascript里定義一個函數(shù)即可

      function window.onbeforeunload() { alert("關閉窗口")}

      alert()事件將會在關閉窗口前執(zhí)行,你也可以用戶決定是否關閉窗口

      function window.onbeforeunload() {  if (event.clientX>document.body.clientWidth && event.clientY<0 ||event.altKey)  window.event.returnValue="確定要退出本頁嗎?";  }

      2.用onUnload方法

      在body 標簽里加入onUnload事件

      body onUnload="myClose()"

      然后在javascript里定義myClose()方法

      但是onUnload方法是在關閉窗口之后執(zhí)行,不是在關閉窗口之前執(zhí)行,如果你想在關閉窗口之前做判斷,請用第一種方法

      以上兩個方法要能夠成功關閉窗口,則該窗口必須是獨立的新窗口;如果是基于父窗口,那么是無法關閉的。

      <!doctype html> <html> <head> <meta charset="utf-8"> <title>導出數(shù)據(jù)</title> <script type="text/javascript"> if(top.location != self.location ) { top.location = self.location; }   var time = 5; //時間,秒 function Redirect() {     //window.location = "http://www.cssue.com/";     window.opener=null; window.open('','_self'); window.close(); } var i = 0; function dis() { if( i > time ) { Redirect(); }     document.all.t.innerHTML = "還剩<span style='color:red'>" + (time - i) + "</span>秒,本頁面將自動關閉";     i++; } timer = setInterval('dis()', 1000); //顯示時間 timer = setTimeout('Redirect()', time * 1000); //跳轉(zhuǎn)   </script> </head> <body > <div style="text-align:center;margin-top:5%"> <h1> <div id="s">Sorry ! 您輸入的信息在服務器中無法找到</div> <div id="t"></div> </h1> </div> </body> </html>

      相關免費學習推薦:javascript視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號