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

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

怎么幾秒不顯示?


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

?

? ? ? ? var num=6;


? ? ? ? function demo(){

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

? ? ? ? ? ? num--;

? ? ? ? ? ??

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

? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? window.location.replace("http://www.baidu.com");

? ? ? ? ? ? ? ? }


? ? ? ? ? ? else{


? ? ? ? ? ? ? ??


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


? ? ? ? ? ? }


? ? ? ?}

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


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

? ?

?</script>?


正在回答

5 回答

<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
?
?
?<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
?
? <h1>操作成功</h1><span id="time"></span>秒后返回首頁<a href="#" onclick="javascript:window.history.go(-1);">返回</a>
?<script type="text/javascript"> ?

?

??????? var num=6;


??????? function demo(){
?document.getElementById('time').innerHTML=num;

??????????? num--;

?????????? ?

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

??????????????? ?

????????????????? window.location.replace("http://www.baidu.com");

??????????????? }


??????????? else{


?????????????? ?


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


??????????? }


?????? }
demo();
?

? ?

?</script>
</body>
</html>
?
</body>
</html>

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

果凍上樹 提問者

非常感謝!
2016-03-31 回復 有任何疑惑可以回復我~

<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h3>操作成功</h3>
? <span id="fh"></span>秒后回到主頁
? <a href="javascript:window.history.back()">返回</a>
?
?
? <script type="text/javascript"> ?
?
?? //獲取顯示秒數的元素,通過定時器來更改秒數。
??? var i = 5;
??? var a = document.getElementById("fh");
??? setInterval("timer()",1000);
?? //通過window的location和history對象來控制網頁的跳轉。
?? function timer(){
??????? if(i == 0){
??????????? window.location.href=window.history.back();
??????? }else{
??????????? a.innerHTML=i; ?
??????????? i--;
??????? }
??? }
???? ?
? ?
?</script>
</body>
</html>

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

在body里面還需要加一個onload="demo(){"

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

<h1>操作成功</h1>

<span id="time"></span>秒后返回首頁<a href="#" onclick="javascript:window.history.go(-1);
">返回</a>

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

你網頁顯示的代碼呢?

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

舉報

0/150
提交
取消
JavaScript進階篇
  • 參與學習       468835    人
  • 解答問題       22582    個

本課程從如何插入JS代碼開始,帶您進入網頁動態交互世界

進入課程

怎么幾秒不顯示?

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

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

幫助反饋 APP下載

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

公眾號

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