请问 8-17 编程练习 中 5秒后跳转到 慕课主页 后, setInterval("count()",1000);还在执行么?
请问 8-17 编程练习 中 5秒后跳转到 慕课主页 后, setInterval("count()",1000);还在执行么?
部分代码如下:
<body>
<!--先编写好网页布局-->
<h2>操作成功</h2>
<p><span id="seconds">5</span>
秒后回到主页 <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>