課程
/前端開發(fā)
/JavaScript
/JavaScript進階篇
自己看不出來還是沒看出來到底哪里出了問題,求解惑
2016-03-10
源自:JavaScript進階篇 8-17
正在回答
你要求還真多:
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h2>操作成功</h2>
? <p><span>5</span>秒后回到主頁<a href="javascript:history.go(-1)">返回</a></p>?
? <script type="text/javascript"> ?
? ? ? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ? function open(){
? ? ? ? window.location.assign('http://idcbgp.cn'); ? ?
? ? }
//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? var time = document.getElementsByTagName('span')[0].innerHTML;
? function timer(){
? ? time = time-1; ??
? ? document.getElementsByTagName('span')[0].innerHTML = time;?
? ? if(time < 1)open(); ??
? }
? setInterval(timer,1000);
?</script>?
</body>
</html>
qq_慕斯_2 提問者
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>操作成功</h1>
<div class="kaka">
<span id="sp">
</span>
秒之后返回主頁面
</div>
<script type="text/javascript">
var b=5;
document.getElementById("sp").innerHTML=b;
function a(){
if(b==0){
window.location.href="http://idcbgp.cn/";
}
else{
b--;
setInterval("a()",1000);
</script>
你要的動態(tài)效果
那就這樣:
? setTimeout(open,time+'000');
騷年??你搞得太復(fù)雜了!
<!DOCTYPE html><html>?<head>? <title>瀏覽器對象</title>? ? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>?? ?</head>?<body>? <!--先編寫好網(wǎng)頁布局-->? <h2>操作成功</h2>? <p>5秒后回到主頁<a href="javascript:history.go(-1)">返回</a></p> ? <script type="text/javascript">??????? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
??? function open(){??????? window.location('http://idcbgp.cn');??? ??? }
? setTimeout(open,1000);?</script> </body></html>
舉報
本課程從如何插入JS代碼開始,帶您進入網(wǎng)頁動態(tài)交互世界
2 回答不知道問題在哪里?哪位大俠知道問題在哪里? 沒有內(nèi)容輸出
2 回答不知道錯在哪里?
3 回答哪位大神知道問題出在哪
3 回答不知道錯在哪里
1 回答不知道哪里出問題了,請指教
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-03-10
你要求還真多:
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h2>操作成功</h2>
? <p><span>5</span>秒后回到主頁<a href="javascript:history.go(-1)">返回</a></p>?
? <script type="text/javascript"> ?
? ? ? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ? function open(){
? ? ? ? window.location.assign('http://idcbgp.cn'); ? ?
? ? }
//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? var time = document.getElementsByTagName('span')[0].innerHTML;
? function timer(){
? ? time = time-1; ??
? ? document.getElementsByTagName('span')[0].innerHTML = time;?
? ? if(time < 1)open(); ??
? }
? setInterval(timer,1000);
?</script>?
</body>
</html>
2016-03-12
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>操作成功</h1>
<div class="kaka">
<span id="sp">
</span>
秒之后返回主頁面
</div>
<script type="text/javascript">
var b=5;
document.getElementById("sp").innerHTML=b;
function a(){
document.getElementById("sp").innerHTML=b;
if(b==0){
window.location.href="http://idcbgp.cn/";
}
else{
b--;
}
}
setInterval("a()",1000);
</script>
</body>
</html>
你要的動態(tài)效果
2016-03-10
那就這樣:
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h2>操作成功</h2>
? <p><span>5</span>秒后回到主頁<a href="javascript:history.go(-1)">返回</a></p>?
? <script type="text/javascript"> ?
? ? ? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ? function open(){
? ? ? ? window.location.assign('http://idcbgp.cn'); ? ?
? ? }
//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? var time = document.getElementsByTagName('span')[0].innerHTML;
? setTimeout(open,time+'000');
?</script>?
</body>
</html>
2016-03-10
騷年??你搞得太復(fù)雜了!
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h2>操作成功</h2>
? <p>5秒后回到主頁<a href="javascript:history.go(-1)">返回</a></p>
? <script type="text/javascript">??
????? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
??? function open(){
??????? window.location('http://idcbgp.cn');???
??? }
//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? setTimeout(open,1000);
?</script>
</body>
</html>