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

路过就不要错过
<html>
 <head>
  <title> New Document </title>
  <script type="text/javascript">
  <!--
  window.onload=function()
  {
  var two=document.getElementById("two");
var three=document.getElementById("three");
setTimeout("window.close()",5000);
var p=document.createElement("p");
function aa()
{
for(var i=5;i>=1;1--)
{
p.innerHTML=parseInt(i);
}  
  }  
three1=two.lastChild;
two.insertBefore(p,three1); 
  setTimeout("aa()",1000);
  }
  //-->
  </script>
 </head>
 <body>
 <div id="two">
<center id="three">
  <h6>正在关闭.......</h6>
  </center>
 </div>
 </body>
</html>
我想做一个关闭网页倒计时的,上述是我写的,不知道哪里错了,请大侠们指点迷津!!!!!!!

------解决方案--------------------
1:是i--,不是1--
2:你的代码我测试不了。改了你的,随便整了个
HTML code
<html>
 <head>
  <title> New Document </title>
  <script type="text/javascript">
    var i=5;
    function aa(){
        i--;
        var p=document.getElementsByTagName("p")[0];
        p.innerHTML=parseInt(i);
        if(i>0){setTimeout("aa()",1000);}
            
    }   
    
window.onload=function(){
    var two=document.getElementById("two");
        var three=document.getElementById("three");
        var p=document.createElement("p");
        three1=two.lastChild;
        two.insertBefore(p,three1);
        p.innerHTML=i;
        
    setTimeout("window.close()",5000);
    setTimeout("aa()",1000);
}

  </script>
 </head>
 <body>
 <div id="two">
    <center id="three">
      <h6>正在关闭.......</h6>
      </center>
 </div>
 </body>
</html>

------解决方案--------------------
呃,第二个关闭窗口的定时器也没必要设置。
HTML code
<html>
 <head>
  <title> New Document </title>
  <script type="text/javascript">
    var i=5;
    function aa(){
        i--;
        var p=document.getElementsByTagName("p")[0];
        p.innerHTML=parseInt(i);
        if(i>0){setTimeout("aa()",1000);}else{window.close()}
    }   
    
window.onload=function(){
    var two=document.getElementById("two");
    var three=document.getElementById("three");
    var p=document.createElement("p");
    three1=two.lastChild;
    two.insertBefore(p,three1);
    p.innerHTML=i;
    setTimeout("aa()",1000);
}

  </script>
 </head>
 <body>
 <div id="two">
    <center id="three">
      <h6>正在关闭.......</h6>
      </center>
 </div>
 </body>
</html>

------解决方案--------------------
JScript code
<html>
  <head>
   <title> New Document </title>
   <script type="text/javascript">
window.onload=function(){
    var two=document.getElementById("two");
    var three=document.getElementById("three");
        setTimeout("window.close()",5000);
    var p=document.createElement("p");
    p.setAttribute("id","time_show");      //添加id的属性,方面下面的值的变化
    p.appendChild(document.createTextNode(""));//这个是在初始化该P元素的值,可以不初始化
    var three1=two.lastChild;
    two.insertBefore(p,three1);  
    
    aa();//初始化时,第一次执行,之后会被setTimeout函数一直执行
}
    v