為什么我的代碼把瀏覽器搞爛了?
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?<h1>操作成功</h1>
?</head>
?<body>
? <!--先編寫好網頁布局-->
?<p>
? ? ?<span id="a"></span>秒后回到主頁
? ? ?<form>
? ? ? ? ?<input type="button" onclick="countdown()" value="返回" />
? ? ? ? ?</form>
? ? ?</p>
??
?
? <script type="text/javascript"> ?
? ?var count=5;
? ?var timer=document.getElementById("a");
? ?timer.innerHTML=count;
? ?function countdown(){
? ?if(timer.innerHTML>0){
? ? ? ?timer.innerHTML=timer.innerHTML-1;
? ?}
? ?setInterval("countdown()",1000);
? ?}
? ?if(timer.innerHTML==0){
? ? ? ?window.history.go(-1);
}
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?
?</script>?
</body>
</html>
而且還不能返回
2017-06-03
不要寫==0,寫<0試試呢