问答详情
源自:8-17 编程练习

高手求助,为什么写完没效果呢,而且浏览器预览也是乱码?


代码如下:

<!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.imooc.com");}

       document.getElementById("second").innerHTML=num;

       num--;

 setTimeout("startCount()",1000);

 

 function backup() {window.history.back();}

 startCount()  

   //获取显示秒数的元素,通过定时器来更改秒数。


   //通过window的location和history对象来控制网页的跳转。

   

 </script> 

</body>

</html>


提问者:菩提爱吃梨 2015-09-04 20:42

个回答

  • Y_du
    2015-09-05 08:34:16
    已采纳

    二个问题。第一if(num=0)应该为if(num==0);第二function startCount(){ 应该为function startCount(){},少了}号; setTimeout("startCount()",1000);应该在startCount函数内。