亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

setInterval("count()",1000)改成setTimeout(”count()",1000)為什么就不行

<!DOCTYPE html>

<html>

?<head>

? <title>瀏覽器對象</title> ?

? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??

?</head>

?<body>

? <!--先編寫好網頁布局-->

? <h1>操作成功</h1>

<span id="second" >5</span>

? <span >秒后回到主頁</span>

? <a href="javascript:history.back()">返回</a>

??

??

?

? <script type="text/javascript"> ?

? ? var num=document.getElementById("second").innerHTML;

? ?//獲取顯示秒數的元素,通過定時器來更改秒數。

??

? ? function count()

? ? {

? ? ? ? num--;

? ? ? ? document.getElementById("second").innerHTML=num;

? ? ? ? if(num==0)

? ? ? ? {

? ? ? ? ? ? location.assign("http://www.xianlaiwan.cn");

? ? ? ? }

? ? }

? ? setInterval("count()",1000);

? ?//通過window的location和history對象來控制網頁的跳轉。

? ? function back()

? ? {

? ? ? ?window.history.go();

? ?}

? ?

?</script>?

</body>

</html>


正在回答

2 回答

可以用

<!DOCTYPE html>

<html>

?<head>

? <title>瀏覽器對象</title> ?

? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??

?</head>

?<body>

? <p style="font-size:30px;">操作成功</p>

? <div>

? ? ? ?<span id="aa">5</span>秒后返回主頁

? ? ? <a href="javascript:history.back()">返回</a>

? </div>

??

? <script type="text/javascript"> ?

?var num=5;

?function count(){

? ? document.getElementById("aa").innerHTML=num;

? ? ?num--; ? ?

? ? ?if(num==-1) window.location.href="wwww.xianlaiwan.cn";

? ? ?setTimeout("count()",1000);

? ? ?}

?count(); ?

?</script>?

</body>

</html>


0 回復 有任何疑惑可以回復我~

setTimeout()方法只執行一遍,不會循環使用里面的count方法,只會執行一遍

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

setInterval("count()",1000)改成setTimeout(”count()",1000)為什么就不行

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號