為什么倒計時3 或者4的時候就停止不動了呢?哪里有問題?
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h1>操作成功</h1>
? <span id="daojishi">5</span>
? <span>秒后返回到主頁</span>
? <a href="javascript:back()"> 返回</a>
??
??
? <script type="text/javascript"> ?
? var a=document.getElementById("daojishi").innerHTML;
?function count()
?{
? a=a-1;
? document.getElementById("daojishi").innerHTML=a;
? if(a==0){
? ? ?location.assign("www.xianlaiwan.cn");}
?}
?setTimeout("count()",1000);
?
?
?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?function back(){
? ? ? ?window.history.back();
? ?}
?</script>?
</body>
</html>
2018-05-08
你的count()函數只運行了一次,你應該在count()函數中再加一個setTimeout("count()",1000)讓count()循環
2018-05-08
沒事,互幫互助