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

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

時間減到0秒時不跳轉,怎么辦啊?


<!DOCTYPE html>

<html>

?<head>

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

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

? <style>

? ? ? a{color:blue;text-decoration:underline;}

? </style>

?</head>

?<body>?

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

??

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

<p><span id="s">5</span>秒后回到主頁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a herf="javascript:tiaozhuan()">返回</a></p>

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

? ?var num=5;

? ?var t= setInterval( function sub(){

? ? ? ? num--;

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

? ? ? ? if(num==0){

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

? ? ? ? ? clearInterval(t);

? ?}

? ?},1000);

? ?

? ? ? function tiaozhuan(){

? ? ? ?window.location.back();

? ?}

? ? ?

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

? ?

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

? ?

?</script>?

</body>

</html>

https://img1.sycdn.imooc.com//5c5e84780001576402340102.jpg


正在回答

2 回答

window.location.replace

而不要用 window.location.href

1 回復 有任何疑惑可以回復我~
#1

太陽會發光呀 提問者

機智!!!!!!!!謝謝啦。。。。
2019-02-10 回復 有任何疑惑可以回復我~

href 是 location 的屬性,而不是方法,所以要用的話應該這樣寫: location.href="http://www.xianlaiwan.cn";?

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

舉報

0/150
提交
取消

時間減到0秒時不跳轉,怎么辦?。?/h1> 我要回答 關注問題

微信客服

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

幫助反饋 APP下載

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

公眾號

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