<!DOCTYPE html>
<html>
 <head>
  <title>浏览器对象</title>  
  <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>   
 </head>
 <body>
  <!--先编写好网页布局-->
  <h1>操作成功</h1><br>
  <div><span id="second">5</span>秒后回到主页 <a href="#" onclick="way()">返回</a>
  </div>
 
  
 
  <script type="text/javascript">  
 
   //获取显示秒数的元素,通过定时器来更改秒数。
  
  var i=5;
   function clock(){
        document.getElementById("second").innerHTML=i;
       i=i-1;
   if(i=0){
       window.location.assign("http://www.imooc.com");
   } 
   }
  
   setInterval("clock()",1000);
   //通过window的location和history对象来控制网页的跳转。
   function way(){
       window.history.back();
   }
   
 </script> 
</body>
</html>
if(i=0) 错了 是 i==0
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h1>操作成功</h1><br>
<div><span id="second">5</span>秒后回到主页 <a href="#" onclick="way()">返回</a>
</div>
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
window.onload =function(){
setInterval("clock()",1000);
}
var i=5;
function clock(){
document.getElementById("second").innerHTML= i;
i--; //直接i--就好了,不用想太多!
if(i<=0){
window.location.assign("http://www.imooc.com");
}
}
//通过window的location和history对象来控制网页的跳转。
function way(){
window.history.back();
}
</script>
</body>
</html>