奧運倒計時<span id="timeDate">載入天數...</span><span id="times">載入倒計時秒...</span># f* [+ a9 I! D' {6 C
<script>
) o9 i8 ]$ f; N# O( Z2 avar now = new Date();
3 T) s* \& s0 ^1 }$ n8 p/ q/ ]function createtime(){
8 G- r) Y+ V% n. r. Y, T
5 E; w* J0 ^+ ivar grt= new Date("8/08/2008 20:00:00");, Z4 b2 U- A3 ` ]/ D
* x7 T* e& H V- F3 C. Y# M% inow.setTime(now.getTime()+250);
4 Y) H. J- w3 e' K. edays = (grt - now) / 1000 / 60 / 60 / 24;% `3 b( j+ J7 m6 w( v
dnum = Math.floor(days);
# L1 C1 |; V6 R1 Z7 Ihours = (grt - now) / 1000 / 60 / 60 - (24 * dnum);6 h! R0 b4 h, b8 \% p
hnum = Math.floor(hours);( e/ o4 V; P4 |$ _, n
if(String(hnum).length ==1 ){hnum = "0" + hnum;}0 f4 Z" p( H4 p) H
minutes = (grt - now) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
1 k4 t. O+ Y1 ^3 W& |% mmnum = Math.floor(minutes);
9 ^& s: }" ?! w+ |if(String(mnum).length ==1 ){mnum = "0" + mnum;}
9 U6 f1 [" O% [4 S) Q% p& x- ?+ N5 lseconds = (grt - now) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
- A, {8 K3 j& ~: i% rsnum = Math.round(seconds);
) a& Q$ z: c- V# sif(String(snum).length ==1 ){snum = "0" + snum;}7 r# y# }( ^# K1 T+ J" v" R
+ F. i0 i/ c3 ^& v
document.getElementById("timeDate").innerHTML = dnum+"天";
+ n+ P) `; i/ mdocument.getElementById("times").innerHTML = hnum + ":" + mnum + ":" + snum;
- Z( \+ y p) }: ?' w}
5 d- K4 A4 v* x: q1 Z" s) u4 ~" M" W L; v( Y) S& N7 e, M
setInterval("createtime()",250);
2 x9 T$ S. Z+ n4 a</script>
P8 w" V7 z2 R: x5 S0 I
4 j5 A" B ^5 X4 \
, X% B7 F& o3 y& B& S j8 r4 t9 @0 _. w
演示:http://www.zzwang.com/ |
|