為什么我的秒數(shù)變得好快,都沒到1S,大神們幫看下
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h3>操作成功</h3>
? <p><span id="seconds"></span>秒后回到主頁<a href="javascript:back1()">返回</a></p>
??
??
?
? <script type="text/javascript">??
?var time=5;
function clock(){
? ? document.getElementById("seconds").innerHTML=time;?//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ? time=time-1;
? ? if(time==0){
? ? ? ? location.assign("http://idcbgp.cn/");?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ? ? ? clearInterval(i);
? ? }
}
var i=setInterval("clock()",1000);
? ?function back1(){
? ? ? ?history.back();
? ?}
?</script>?
</body>
</html>
2018-12-10
復(fù)制到自己的編輯器里面試試 網(wǎng)頁里面的那個編輯器 會和瀏覽器重復(fù)解析 速度會有問題
2018-12-21
直接點擊返回沒效果啊
2018-12-13
沒什么問題,但是你要注意最開始還是寫一個5在span里面,不然你那個數(shù)字出來太突兀了
2018-12-08
那好不清楚了,我這里時間變化得不對
2018-12-08
測試了你的代碼,沒什么問題啊