麻煩大神幫我看看我的代碼哪里有問題?秒數(shù)一直沒變化啊
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h1>操作成功</h1>
? <p><span id="sec">5</span>秒后回到主頁<a href="javascript:backnow()">返回</a></p>
??
?
? <script type="text/javascript"> ?
?var num=5
?function daoji()
?{ ??
? ? ?if(num==0}{location.assign='http://idcbgp.cn'}
? ? ?document.getElementById('sec').innerHTML=num;
? ? ?num=num-1;}
? ? ?setInterval(daoji,1000);
? ?//獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
?function backnow(){
? ? ?window.history.go(-1);
?}
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?
?</script>?
</body>
</html>
2016-06-03
大哥,你function daoji()方法里面,判斷語句?if(num==0),你寫?if(num==0},肯定錯(cuò)啊
2016-06-03
1) if(num==0}寫錯(cuò)
2){location.assign='http://idcbgp.cn'} 寫錯(cuò)