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