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