zoukankan      html  css  js  c++  java
  • 倒计时代码精确到秒

    <div id="TimeCounter" style="border:1px solid black;margin:1px;padding:2px;300px"></div>
    <SCRIPT language=javascript>
    <!--
    function show_date_time(){
     window.setTimeout("show_date_time()", 1000);
     target=new Date(2008,8,8,20,00,00);
     today=new Date();
     timeold=(target.getTime()-today.getTime());
     
     sectimeold=timeold/1000
     secondsold=Math.floor(sectimeold);
     msPerDay=24*60*60*1000
     e_daysold=timeold/msPerDay
     daysold=Math.floor(e_daysold);
     e_hrsold=(e_daysold-daysold)*24;
     hrsold=Math.floor(e_hrsold);
     e_minsold=(e_hrsold-hrsold)*60;
     minsold=Math.floor((e_hrsold-hrsold)*60);
     seconds=Math.floor((e_minsold-minsold)*60);
     
      if (daysold<0) {
     document.getElementByIdx_x_x("TimeCounter").innerHTML="逾期,倒计时已经失效";
    }
     else{
     if (daysold<10) {daysold="0"+daysold}
     if (daysold<100) {daysold="0"+daysold}
     if (hrsold<10) {hrsold="0"+hrsold}
     if (minsold<10) {minsold="0"+minsold}
     if (seconds<10) {seconds="0"+seconds}
     if (daysold<3) {
      document.getElementByIdx_x_x("TimeCounter").innerHTML="离奥运会开幕还有"+daysold+""+hrsold+"小时"+minsold+""+seconds+"";
    }
     else
      document.getElementByIdx_x_x("TimeCounter").innerHTML="离奥运会开幕还有" + daysold+""+hrsold+"小时"+minsold+""+seconds+"";
    }
    }
    show_date_time();
    //-->
    </SCRIPT></div>
     
    ***************************到某个时间自动转向另一个页面***************************************
     
    <span id="span_dt_dt" style='border:1px solid black;background-color:#FFFFFF' ></span>
    <script language=javascript>
    <!--
    function show_student163_time(){
    window.setTimeout("show_student163_time()", 1000);
    BirthDay=new Date("2010/11/02 11:55:00");//改成你的计时日期
    today=new Date();
    timeold=(BirthDay.getTime()-today.getTime());
    sectimeold=timeold/1000
    secondsold=Math.floor(sectimeold);
    msPerDay=24*60*60*1000
    e_daysold=timeold/msPerDay
    daysold=Math.floor(e_daysold);
    e_hrsold=(e_daysold-daysold)*24;
    hrsold=Math.floor(e_hrsold);
    e_minsold=(e_hrsold-hrsold)*60;
    minsold=Math.floor((e_hrsold-hrsold)*60);
    seconds=Math.floor((e_minsold-minsold)*60);
    if(daysold>=0&&hrsold>=0&&minsold>=0&&seconds>0)
    {
    span_dt_dt.innerHTML=daysold+""+hrsold+"小时"+minsold+""+seconds+"" ;
    }
    else
    {
     location.href="http://www.baidu.com/";
    }
    }
    show_student163_time();
    //-->
    </script>
  • 相关阅读:
    译码器(选择器)
    RAM搭建
    ALU运算
    Base64
    关于Singleton
    C# WinForm导出Excel
    windows phone 前台布局以及画刷Brush使用 北京
    点击控件出现下沉或者倾斜技巧。(是你的控件不在死板,) 北京
    Centos5.4+Nginx+mysql5+php5+Zend3.3.3详细安装教程(转载请注明formating编写)
    如何锻炼身体
  • 原文地址:https://www.cnblogs.com/Chaser-Eagle/p/3684999.html
Copyright © 2011-2022 走看看