为什么我的秒数变得好快,都没到1S,大神们帮看下
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h3>操作成功</h3>
<p><span id="seconds"></span>秒后回到主页<a href="javascript:back1()">返回</a></p>
<script type="text/javascript">
var time=5;
function clock(){
document.getElementById("seconds").innerHTML=time; //获取显示秒数的元素,通过定时器来更改秒数。
time=time-1;
if(time==0){
location.assign("https://www.imooc.com/"); //通过window的location和history对象来控制网页的跳转。
clearInterval(i);
}
}
var i=setInterval("clock()",1000);
function back1(){
history.back();
}
</script>
</body>
</html>