這代碼錯(cuò)在那里?。?/h1>
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對(duì)象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <div>
? ? ? <h1>操作成功</h1>
? ? ? <span id="second">5</span>秒后回到主頁<a href="http://idcbgp.cn">返回</a>
? </div>
??
?
? <script type="text/javascript"> ?
?var n=document.getElementById("second").innerHtml,
var e= setInterVal("count()",1000)
? ?//獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
function count(){
? ? n=n-1;
? ? if(n==0){
? ? ? ?window.location.assign("http://widcbgp.cn")
? ??
? ? };
? ??
}
? ?//通過window的location和history對(duì)象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?
?</script>?
</body>
</html>
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對(duì)象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <div>
? ? ? <h1>操作成功</h1>
? ? ? <span id="second">5</span>秒后回到主頁<a href="http://idcbgp.cn">返回</a>
? </div>
??
?
? <script type="text/javascript"> ?
?var n=document.getElementById("second").innerHtml,
var e= setInterVal("count()",1000)
? ?//獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
function count(){
? ? n=n-1;
? ? if(n==0){
? ? ? ?window.location.assign("http://widcbgp.cn")
? ??
? ? };
? ??
}
? ?//通過window的location和history對(duì)象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?
?</script>?
</body>
</html>
2016-09-20
? "var n=document.getElementById("second").innerHtml"中的“innerHtml”正確寫法為“innerHTML”;
最好在“n=n-1”下面接上“document.getElementById("second").innerHTML=n;? ”來顯示時(shí)間動(dòng)態(tài)改變;
點(diǎn)擊“返回”,應(yīng)該加一個(gè)方法
function back(){
?????? window.history.back();
?? }
而不是直接加鏈接。