[代码] 页面定时跳转代码html+js

[复制链接]
本站网友  发表于 2019-10-22 17:29 |阅读模式

定时跳转

页面定时跳转代码

1.content="5 定时5秒进行跳转,可随便设置需要的数字。url=设置需要跳转到的连接 。
  1. <meta http-equiv="Refresh" content="5;URL=https://www.baidu.com/" />
复制代码
把代码放在网页haed中间即可

2.location.href=设置需要跳转到的连接,var time =设置时间 ,以下代码放在head中间
  1. <script type="text/j.ascript">
  2.     window.onload = function(){
  3.         var time = 5;
  4.         var secondEle = document.getElementById("second");
  5.         var timer = setInterval(function(){
  6.             secondEle.innerHTML = time;
  7.             time--;
  8.             if(time==0){
  9.                 clearInterval(timer);
  10.                 location.href="http://www.baidu.com";
  11.             }

  12.         },1000);
  13.     }
  14. </script>
复制代码
以下代码放在body内
  1.     <span style="color:red" id="second">5</span>秒钟后跳转,如不跳转点击<a href="http://www.baidu.com">这里</a>!
复制代码

QQ|删帖注销|手机版|资源圈

GMT+8, 2024-5-5 12:53

Powered by Discuz!

© 20022-2026 Comsenz Inc.

快速回复 返回顶部 返回列表