日期:2014-05-16  浏览次数:20388 次

javascript 读秒提示并自动定时关闭页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>自动关闭页面</title>
    <script type="text/javascript">
    setTimeout("closeWindow()",1000);
    var sec = 0;
    function closeWindow() {
    sec ++;
// 此处设置多少秒关闭。
    if(sec == 10) {
    window.opener=null;
    window.open('','_self');
    self.close();
    return false;
    }
    var sy = (10 - sec);
    document.all.time.innerHTML = sy;
    setTimeout("closeWindow()",1000);
    }
    </script>
  </head>
 
  <body>
    <font color="#999999"<label id="time">10</label></font>&nbsp;秒内关闭窗口,如未关闭,请点击<a href="javascript:window.close()">关闭</a>
  </body>
</html>