<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h3>操作成功</h3>
<span id="num">5</span>秒后返回主页<a href="back()">返回</a>
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
var num=4;
var timer=setInterval(function(){
var oNum=document.getElementById('num');
oNum.innerHTML=num;
num--;
if(num==0){
clearInterval(timer);
window.location="http://www.imooc.com";
}
},1000)
//通过window的location和history对象来控制网页的跳转。
function back(){
window.location.go(-1);
}
</script>
</body>
</html>