请问 8-17 编程练习 中 5秒后跳转到 慕课主页 后, setInterval("count()",1000);还在执行么?

来源:8-17 编程练习

ZF_Steven

2015-06-05 22:31

请问 8-17 编程练习 中 5秒后跳转到 慕课主页 后,  setInterval("count()",1000);还在执行么?

部分代码如下:
<body>
  <!--先编写好网页布局-->
  <h2>操作成功</h2>
  <p><span id="seconds">5</span>
  秒后回到主页&nbsp;<a href = "javascript:history.back()">返回</a></p>
 
 
  <script type="text/javascript"> 
 
   //获取显示秒数的元素,通过定时器来更改秒数。
   var num =document.getElementById("seconds").innerHTML;
  
   function count(){
    num--;
    document.getElementById("seconds").innerHTML = num;
    if (num == 1){
    window.location.assign("http://www.imooc.com")   
    }  
}
   //通过window的location和history对象来控制网页的跳转。
   setInterval("count()",1000);
   function back(){
    window.history.back();  
   }
 </script>
</body>

写回答 关注

1回答

  • 伊兮尘昔
    2015-06-08 14:42:27

    clearInterval停止掉

JavaScript进阶篇

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

468375 学习 · 21893 问题

查看课程

相似问题