<div class="codetitle"> <span><a style="CURSOR: pointer" data="5643" class="copybut" id="copybut5643" onclick="doCopy('code5643')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code5643"> <br> <br> <br><meta http> <meta http> <meta content="text/html; charset=utf-8"> <br><title>5秒後跳到另一個頁面</title> <br><br><script type="text/javascript"> <BR>var t = 5; <BR>function countDown(){ <BR>var time = document.getElementById("time"); <BR>t--; <BR>time .value=t; <BR>if (t<=0) { <BR>location.href="http://www.baidu.com"; <BR>clearInterval(inter); <BR>}; <BR>} <BR>var inter = setInterval("countDown()",1000); <BR>//window.onload=countDown; <BR></script> <br><br> <br> <br><br><input type="text" readonly value="5" id="time"> <br><br><!--也可以在這裡寫javascript程式碼,這樣就不必在body標籤裡寫onload="countDown()"。 --> <br> <br> <br> </div>