我加了一個if,為什么沒有生效,后面的if就生效了?求指教
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h1>caozuo is ok!</h1>
??
? <p><span id="aa">5</span>秒后返回主頁,<a href="javascript:back();">返回</a></p>
? <button id = "bt" onclick="count()">start</button>
? <script type="text/javascript">??
? num=document.getElementById("aa").innerHTML
? //document.write(num)
??
? function count(){?
? ? ? num--;
? ? ? document.getElementById("aa").innerHTML=num;
? ? ? if(num==0){
? ? ? ? ? window.open("www.baidu.com","_blank","width=120 height=44")
? ? ? }
//這里的代碼沒有生效,為什么
? ? ?i=setTimeout("count()",1000)
? ? ?if(num==0){clearTimeout(i)}?
? }?
??
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
??
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?
?</script>?
</body>
</html>
2019-06-01
那段代碼是生效了的,跳出了一個窗口。但是沒有正確跳轉到baidu.com,你試試把url改為https://www.baidu.com
2019-04-20
后面的把前面的覆蓋了?