Js implements the dynamic countdown function * a is the timestamp received from the background, which must be converted to milliseconds
01
<Div>
02
There will be:
03
<Span id = 'day'> </span> days
04
<Span id = 'ursa '> </span> hour
05
<Span id = 'minua '> </span>
06
<Span id = 'secoa '> </span> seconds
07
</Div>
08
<Script type = "text/javascript">
09
/**
10
*
11
* Copyright Liu Xiaobo 2012.7
12
* Js implements the dynamic countdown Function
13
* A is the timestamp received from the background, which must be converted to the unit of milliseconds.
14
*
15
*/
16
Var a = 12345678; // in milliseconds
17
Function fomtime ()
18
{
19
A = a-1000;
20
Var B = new Date ();
21
B. setTime (0 );
22
Var c = new Date ();
23
C. setTime ();
24
Var day1 = B. getDate (); // for convenient calling, separate the days and hours
25
Var hours1 = B. getHours ();
26
Var minu1 = B. getMinutes ();
27
Var seco1 = B. getSeconds ();
28
Var day2 = c. getDate ();
29
Var hours2 = c. getHours ();
30
Var minu2 = c. getMinutes ();
31
Var seco2 = c. getSeconds ();
32
Var day = day2-day1;
33
Var hours = hours2-hours1;
34
Var minu = minu2-minu1;
35
Var seco = seco2-seco1;
36
Document. getElementById ('daya'). innerHTML = day;
37
Document. getElementById ('ursa '). innerHTML = hours;
38
Document. getElementById ('minua '). innerHTML = minu;
39
Document. getElementById ('secaca'). innerHTML = seco;
40
SetTimeout ("fomtime ()", 1000 );
41
}
42
Fomtime ();
43
</Script>
Author: The power of dedication