zoukankan      html  css  js  c++  java
  • js设置定时器在规定的日期内替换掉页面

    <script type="text/javascript">
      window.onload=function(){
        var myspan=document.getElementById("myspan");

        var datas = Math.ceil((new Date(" 2019/06/21 13:07:00")).getTime()/1000);//定义时间戳
        var aaa = Math.ceil(new Date().getTime()/1000); //获取当前时间
        console.log('datas==>>', datas)
        console.log('aaa==>>', aaa)

        var timer=datas - aaa;/*倒计时的秒数*/
        var flag;

        function daojishi(){
          timer=timer-1;/*每一秒钟减一秒*/
          myspan.innerHTML=timer;
          if(timer==0){
            location.href="http://www.baidu.com";/*所要跳转到的网址*/
            clearInterval(flag);/*清除循环*/
          }
        }
        flag=setInterval(daojishi,1000);/*每一秒执行一次该函数*/
      }
    </script>

  • 相关阅读:
    [Leetcode]@python 89. Gray Code
    [Leetcode]@python 88. Merge Sorted Array.py
    [Leetcode]@python 87. Scramble String.py
    [Leetcode]@python 86. Partition List.py
    [leetcode]@python 85. Maximal Rectangle
    0523BOM
    0522作业星座
    0522dom
    0520
    0519作业
  • 原文地址:https://www.cnblogs.com/hermit-gyqy/p/11058321.html
Copyright © 2011-2022 走看看