高手求助,為什么寫完沒效果呢,而且瀏覽器預覽也是亂碼?
代碼如下:
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h2>操作成功</h2>
? <span id='second'></span> 秒后回到主頁 <a href="javascript:back()">返回</a>
? ?<script type="text/javascript">
? ? var num=5
?function startCount(){
? ? ? ?if(num=0){location.assign("http://www.xianlaiwan.cn");}
? ? ? ?document.getElementById("second").innerHTML=num;
? ? ? ?num--;
?setTimeout("startCount()",1000);
?
?function backup() {window.history.back();}
?startCount() ?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?
?</script>?
</body>
</html>
2015-09-05
二個問題。第一if(num=0)應該為if(num==0);第二function startCount(){ 應該為function startCount(){},少了}號;?setTimeout("startCount()",1000);應該在startCount函數內。