当前位置: 移动技术网 > IT编程>开发语言>JavaScript > HTML页面定时跳转方法解析(2种任选)

HTML页面定时跳转方法解析(2种任选)

2019年04月03日  | 移动技术网IT编程  | 我要评论

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

1、通过 meta refresh 实现 3 秒后自动跳转到 页面。

<!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 秒后自动跳转到   页面。

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

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持移动技术网!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网