5秒之后页面不能跳转???
我的代码运行不出来呢,5秒之后根本不跳转,是什么原因呀?
我的代码运行不出来呢,5秒之后根本不跳转,是什么原因呀?
2016-05-20
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h2>操作成功</h2>
<span id = "num">5</span>秒后返回主页 <a href="#" onclick = "window.history.back()">返回</a>
<script type="text/javascript">
var num = 5;
function count(){
//获取显示秒数的元素,通过定时器来更改秒数。
document.getElementById("num").innerHTML = num;
//通过window的location和history对象来控制网页的跳转。
if(num == 0){
clearInterval(timeout);
}
num --;
}
var timeout = setInterval(count,1000);
</script>
</body>
</html>举报