<!DOCTYPE?html>
<html>?
<head>??
<title>瀏覽器對(duì)象</title>????
<meta?http-equiv="Content-Type"?content="text/html;?charset=gkb"/>????
</head>?
<body>??
<!--先編寫好網(wǎng)頁(yè)布局-->????
<p><b>操作成功</b></p>??
<p><span?id='num1'>5</span>秒后回到主頁(yè)?<a?href="history()">返回</a></p>???????
<script?type="text/javascript">?????
var?num=?document.getElementById('num1').innerHTML???
//獲取顯示秒數(shù)的元素,通過定時(shí)器來(lái)更改秒數(shù)。???
console.log(num)???
function?number(){???????
num--;???????
ocument.getElementById('num1').innerHTML=num???????
if(num==0){???????????
location.assign("http://idcbgp.cn");???????
}??????
etTimeout('number()',1000)???
}??????s
etTimeout('number()',1000)???
//通過window的location和history對(duì)象來(lái)控制網(wǎng)頁(yè)的跳轉(zhuǎn)。???
function?history(){???????
window.history.back()???
}?
</script>?
</body>
</html>

2018-12-17
就我看來(lái),你的代碼有以下幾個(gè)問題。
1:17行? document寫錯(cuò)了,ocument.
2:21,22行,setTimeout寫成了etTimeout
3:
<
a
?href
=
"history()"
>返回</
a
></
p
>??
這一句里,雖然JS href標(biāo)簽可以接函數(shù),語(yǔ)法是href="javascript:function()",但是這種寫法不推薦:推薦寫法:href="http://idcbgp.cn" onclick="history()"。
4.你的
number()
函數(shù)內(nèi),location.assign("http://idcbgp.cn");???
改為window.location.assign("http://idcbgp.cn
");2018-12-15
沒有上一頁(yè)吧