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