首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript + 促销记时源码 + fixed固定在底部(兼容IE6)

2013-09-27 
javascript + 促销倒计时源码 +fixed固定在底部(兼容IE6)!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 T

javascript + 促销倒计时源码 + fixed固定在底部(兼容IE6)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>无标题文档</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></head><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);//倒计时ieFixed('lefttime3'); //固定在底部</script></body></html>

1)兼容IE6

2)自动倒计时,输入的数字必须是时间,单位毫秒。


热点排行