JavaScript implementation promotional countdown +fixed fixed at bottom _javascript tips

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<style>
#lefttime3 {background:url (timerbg.jpg) no-repeat left center; width:1018px;height:55px;
Font-size:40px;line-height:55px;font-family:ms Yahei,microsoft Yahei;
Color: #f00; Color:rgb (255,205,1);
}
#day {margin-left:592px;}
#hour {margin-left:40px;}
#min {margin-left:39px;}
#sec {margin-left:37px;}
</style>
<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.exec (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.documentElement.scrollLeft + document.documentelement.clientwidth-312) + "px";
}, 80);
}
}
</script>

<body style= "height:300000px;" >
<div id= "lll" style= "margin:10px;padding:20px; Border:solid 2px #DDD; Background: #fc6; height:300px; " ></div>
<div id= "Lefttime3" style= "position:fixed;bottom:0px;right:0px;" ><span id= "Day" ></span><span id= "Hour" ></span><span id= "min" ></span>< Span id= "SEC" ></span></div>
<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 bottom
</script>
</body>

1) compatible IE6
2 The automatic countdown, the input number must be time, unit milliseconds.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.