我這個秒數走的不正常
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <strong>操作成功</strong><br>
? <span id="txt">5</span>
? <span>秒后回到主頁</span>
? <a href="javascript:back();">返回</a>
?
? <script type="text/javascript">??
?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ? var sum=5;
? ? function time(){
? ? ? ? sum--;
? ? ? ? document.getElementById("txt").innerHTML=sum;
? ? ? ? if(sum==0){
? ? ? ? ? ? lacation.replace("http://www.xianlaiwan.cn");
? ? ? ? }
? ? }
? ? window.setInterval("time()",1000);
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?function back(){
? ? ? ?window.history.back();
? ?}
?</script>?
</body>
</html>
2020-12-15
location單詞拼錯了
未清除定時器