JavaScript實現動態倒計時跳轉頁面
將在5秒後跳轉到stupid.html
其中setTimeout()的第一個參數爲要執行的函數,第二個參數爲時間,單位是毫秒。
<script language="javascript">
function clock(){
i=i-1;
c=document.getElementById("c");
c.textContent="將在 "+i+" 秒後跳轉到stupid.html!";
if(i>0) setTimeout("clock()",1000);
else window.location.href="stupid.html";
}
var i=5
</script>