码迷,mamicode.com
首页 > 其他好文 > 详细

页面的定时跳转

时间:2015-03-19 13:12:51      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

<!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>
                                    

  

页面的定时跳转

标签:

原文地址:http://www.cnblogs.com/LeeYom1993/p/4350008.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!