JavaScript實現動態倒計時跳轉頁面

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>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章