求一段倒计时代码1.htm打开后有 100-0  秒的 的倒计时。跳动数字。数字最好是3位的。时间到了0后,页面转到2.htm。
谢谢大家了

解决方案 »

  1.   

    http://heisetoufa.javaeye.com/blog/355114
      

  2.   


    <script language="JavaScript">
    var nMS = 100;
    function GetRTime(){
    if (nMS<10) nMS = "00"+ nMS;
    else if (nMS<100) nMS = "0"+ nMS;
    document.getElementById("RemainS").innerHTML = nMS;
    if(nMS==0) window.location.href = "2.html";
    else {
    nMS -= 1;
    setTimeout("GetRTime()",1000);
    }
    }
    window.onload=GetRTime;
    </script>
    <div id="CountMsg">还有 <strong id="RemainS"></strong>秒</div>
      

  3.   

    <hmtl>
    <head>
    <script type="text/javascript">
    function countdown() {
    var zero = ["000","00","0",""];
    var p = 100;
    var div = document.getElementById("div");
    var inter = setInterval(function() {
    if (p == 0) {
    window.clearInterval(inter);
    }
    div.innerHTML = "还有" + zero[("" + p).length] + p + "秒";
    p--;
    }, 1000);
    }
    </script>
    </head>
    <body onload="countdown()">
    <div id="div"></div>
    </body>
    </html>
      

  4.   

    +
    ls 2位的思想都可行
    用setTimeout or setInterval即可