我哪里錯了
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h2>操作成功!</h2>
? <a id="count">5</a>
? <a>秒后回到主頁</a>
? <a onclick="back" href="">返回</a>
? <script type="text/javascript">
? ? var num = document.getElementById("count").innerHTML;
? ? function count(){
? ? ? ? num--;
? ? ? ? document.getElementById("second").innerHTML=num;
? ? ? ? if(num==0){
? ? ? ? ? ? location.assign("http://www.xianlaiwan.cn");
? ? ? ? }
? ? }
? ? setInterval("count()",1000);
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?function back(){
? ? ? ?window.history.back();
? ?}
?</script>?
</body>
</html>
2019-11-11
調用方法加括號:<a onclick="back()" href="">返回</a>
沒有定義id為second的節點,改為count:document.getElementById("count").innerHTML=num;