码迷,mamicode.com
首页 > Web开发 > 详细

HTML 定时页面跳转

时间:2016-12-21 23:48:01      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:refresh   type   ext   跳转   cti   com   div   class   tin   

有 2 种方法可以实现 html 的定时页面跳转,1、meta refresh 实现。2、JavaScript 实现。

1、通过 meta refresh 实现 3 秒后自动跳转到 http://www.cnblogs.com/wuxibolgs329/ 页面。

<!doctype html>
    <html>
      <head>
      <meta charset="utf-8">
      <title>前端笔记</title>
      <meta http-equiv="refresh" content="3;url=http://www.cnblogs.com/wuxibolgs329/">
    </head>
  <body>
  </body>
</html>

2、通过 JavaScript 实现 8 秒后自动跳转到 http://www.cnblogs.com/wuxibolgs329/  页面。

<!doctype html>
  <html>
    <head>
      <meta charset="utf-8">
      <title>前端笔记</title>
      <script type="text/javascript">
        var time = 8; //时间,秒
        function Redirect() {
            window.location = "http://www.cssue.com/";
        }
        var i = 0;
        function dis() {
            document.all.s.innerHTML = "还剩" + (time - i) + "";
            i++;
        }
        timer = setInterval(dis(), 1000); //显示时间
        timer = setTimeout(Redirect(), time * 1000); //跳转
      </script>
  </head>
  <body>
    <span id="s"></span>
  </body>
</html>

 

HTML 定时页面跳转

标签:refresh   type   ext   跳转   cti   com   div   class   tin   

原文地址:http://www.cnblogs.com/wuxibolgs329/p/6209445.html

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