A good example is a sales countdown implemented using javascript, with fixed at the bottom and compatible with ie6. If you like it, refer
The Code is as follows:
Untitled document
Script
Var djs = function (d, o)
{
Var f = {
Zero: function (n ){
Var n = parseInt (n, 10 );
If (n> 0 ){
If (n <= 9) n = '0' + n;
Return String (n );
} Else {
Return '00 ';
}
},
Run: function (){
Var ts = Math. round (new Date (d). getTime ()-new Date (). getTime ()/1000 );
If (o & ts> 0)
{
Var yy = Math. floor (ts/31556926 );
Var mm = Math. floor (ts/2629744); mm = mm> 0? Mm % 12: '00 ';
Var dd = Math. floor (ts/86400); dd = dd> 0? Dd % 30: '00 ';
Var hh = Math. floor (ts/3600); hh = hh> 0? Hh % 24: '00 ';
Var ii = Math. floor (ts/60); ii = ii> 0? Ii % 60: '00 ';
Var ss = Math. floor (ts % 60 );
If (o. y) o. y. innerHTML = f. zero (yy );
If (o. m) o. m. innerHTML = f. zero (mm );
If (o. d) o. d. innerHTML = f. zero (dd );
If (o. h) o. h. innerHTML = f. zero (hh );
If (o. I) o. I. innerHTML = f. zero (ii );
If (o. s) o. s. innerHTML = f. zero (ss );
}
Window. setTimeout (f. run, 1000 );
}
}
F. run ();
}
Function ieFixed (id)
{
Var isIE = (document. all )? True: false;
Var isIE6 = isIE & ([/MSIE (\ d) \. 0/I .exe c (navigator. userAgent)] [0] [1] = 6 );
Var obj = document. getElementById (id). style;
If (isIE6 & obj)
{
Obj. position = "absolute ";
Obj. bottom = "0px ";
Obj. right = "0px ";
Var tm = window. setInterval (function (){
Obj. marginBottom = "0px ";
Obj. left = (document.doc umentElement. scrollLeft + document.doc umentElement. clientWidth-312) + "px ";
}, 80 );
}
}
Script
Script
Var d = new Date (). getTime () + 3600*24*1000;
Var d = 1379572933131;
Var o = {
D: document. getElementById ('day '),
H: document. getElementById ('hour '),
I: document. getElementById ('Min '),
S: document. getElementById ('sec ')
}
Djs (d, o); // countdown
IeFixed ('lefttime3'); // fixed at the bottom
Script
1) compatible with IE6
2) Automatic countdown. The input number must be time, in milliseconds.