点击返回的时候有用,但是计时的从5计时到-100,就是不跳转,这可咋整

来源:8-17 编程练习

Autism21

2018-11-23 15:57

<!DOCTYPE html>

<html>

 <head>

  <title>浏览器对象</title>  

  <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>   

 </head>

 <body>

  <!--先编写好网页布局-->

  <h1>操作成功</h1>

  <span id="second">5</span>

  <span>秒返回到主页</span>

  <a href id="javascript:back()">返回</a>

 

  <script type="text/javascript">  

 

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

   var num=document.getElementById('second').innerHTML;

   function count() {

        num=num-1;

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

        if(num==1)

        {

           windows.location.assign("https://www.imooc.com/u/4178927/courses");

        }

  }

        setInterval("count()",1000);

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

   function back(){

       window.history.go(-1);

   }

   

 

   

 </script> 

</body>

</html>


写回答 关注

1回答

  • 奋斗的神秘人
    2018-11-24 10:48:41

     window.location.assign("https://www.imooc.com/u/4178927/courses");,window没有s

JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

467398 学习 · 21877 问题

查看课程

相似问题