Team:Tsinghua/try
From 2010.igem.org
(Difference between revisions)
Line 45: | Line 45: | ||
document.getElementById("timeDate").innerHTML = dnum+"DAY"; | document.getElementById("timeDate").innerHTML = dnum+"DAY"; | ||
+ | |||
+ | |||
document.getElementById("times").innerHTML = hnum + ":" + mnum + ":" + snum; | document.getElementById("times").innerHTML = hnum + ":" + mnum + ":" + snum; | ||
} | } | ||
Line 51: | Line 53: | ||
// --></script> | // --></script> | ||
</font></b> | </font></b> | ||
+ | |||
+ | |||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | <head> | ||
+ | <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> | ||
+ | <title>网页特效观止|JsCode.CN|---在您的网页里加入北京奥运倒计时的代码</title> | ||
+ | <script language="JavaScript"> | ||
+ | <!-- hide script from old browser | ||
+ | var DifferenceHour = -1 | ||
+ | var DifferenceMinute = -1 | ||
+ | var DifferenceSecond = -1 | ||
+ | var Tday = new Date("Aug 8, 2008 20:00:00") //**倒计时时间点-注意格式 | ||
+ | var daysms = 24 * 60 * 60 * 1000 | ||
+ | var hoursms = 60 * 60 * 1000 | ||
+ | var Secondms = 60 * 1000 | ||
+ | var microsecond = 1000 | ||
+ | function clock() | ||
+ | { | ||
+ | var time = new Date() | ||
+ | var hour = time.getHours() | ||
+ | var minute = time.getMinutes() | ||
+ | var second = time.getSeconds() | ||
+ | var timevalue = ""+((hour > 12) ? hour-12:hour) | ||
+ | timevalue +=((minute < 10) ? ":0":":")+minute | ||
+ | timevalue +=((second < 10) ? ":0":":")+second | ||
+ | timevalue +=((hour >12 ) ? " PM":" AM") | ||
+ | // document.formnow.now.value = timevalue | ||
+ | var convertHour = DifferenceHour | ||
+ | var convertMinute = DifferenceMinute | ||
+ | var convertSecond = DifferenceSecond | ||
+ | var Diffms = Tday.getTime() - time.getTime() | ||
+ | DifferenceHour = Math.floor(Diffms / daysms) | ||
+ | Diffms -= DifferenceHour * daysms | ||
+ | DifferenceMinute = Math.floor(Diffms / hoursms) | ||
+ | Diffms -= DifferenceMinute * hoursms | ||
+ | DifferenceSecond = Math.floor(Diffms / Secondms) | ||
+ | Diffms -= DifferenceSecond * Secondms | ||
+ | var dSecs = Math.floor(Diffms / microsecond) | ||
+ | if(convertHour != DifferenceHour) document.formnow.dd.value=DifferenceHour | ||
+ | if(convertMinute != DifferenceMinute) document.formnow.hh.value=DifferenceMinute | ||
+ | if(convertSecond != DifferenceSecond) document.formnow.mm.value=DifferenceSecond | ||
+ | document.formnow.ss.value=dSecs | ||
+ | // document.formnow.Tnow.value= DifferenceHour DifferenceMinute + DifferenceSecond + dSecs | ||
+ | setTimeout("clock()",1000) | ||
+ | } | ||
+ | // end hiding --> | ||
+ | </script> | ||
+ | </head> | ||
+ | |||
+ | <body onload="clock();return true"> | ||
+ | |||
+ | 距离北京奥运会开幕还有:<br> | ||
+ | <form name="formnow"> | ||
+ | <input name="dd" type="text" style="border:0;" size="2"> 天 | ||
+ | <input name="hh" type="text" style="border:0;" size="2"> 小时 | ||
+ | <input name="mm" type="text" style="border:0;" size="2"> 分 | ||
+ | <input name="ss" type="text" style="border:0;" size="2"> 秒 | ||
+ | </form> | ||
+ | |||
+ | </body> |
Revision as of 10:33, 10 July 2010