• js实战之-倒计时


     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
     5 <title>js-倒计时</title>
     6 </head>
     7 
     8 <body>
     9 
    10 <div id="box"></div>
    11 
    12 <script language="javascript">
    13 
    14 var timer2=new Date("5/01/2015 00:00:00");
    15 var tim_box=document.getElementById("box");
    16 var yer,days,hors,miu,sec;
    17 function  js(){
    18 var timer=new Date();
    19  yer=Math.floor((timer2-timer)/(365*24*60*60*1000));
    20  days=Math.floor((timer2-timer)/(24*60*60*1000)-(yer*365));
    21  hors=Math.floor((timer2-timer)/(1000*60*60)-(days*24)-(yer*365*24));
    22  miu=Math.floor((timer2-timer)/(60*1000)-(days*24*60)-(yer*365*24*60)-(hors*60));
    23  sec=Math.floor((timer2-timer)/1000-(days*24*60*60)-(yer*365*24*60*60)-(hors*60*60)-(miu*60));
    24 tim_box.innerHTML="距离2015年5月1日还有"+yer+""+days+""+hors+"小时"+miu+"分钟"+sec+"";
    25 setTimeout("js()",1000);
    26 }
    27 js();
    28 </script>
    29 
    30 </body>
    31 </html>
    一个不敬业的前端攻城狮
  • 相关阅读:
    winform中主窗体可以实现拖动代码
    winform中自定义窗体启动位置
    winform中启动登陆窗体,登陆成功后登陆窗体自动销毁
    winform中隐藏窗体边框
    作业2
    画图
    作业
    day01
    java.String中的方法
    网站的内链反链黑链
  • 原文地址:https://www.cnblogs.com/chaoming/p/3183617.html
Copyright © 2020-2023  润新知