Home  >  Article  >  Web Front-end  >  Javascript implements promotion countdown fixed at the bottom_javascript skills

Javascript implements promotion countdown fixed at the bottom_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:22:171068browse
复制代码 代码如下:





无标题文档

<script> <br><br>var djs = function(d,o) <br>{ <br>var f = { <br>zero: function(n){ <br>var n = parseInt(n, 10); <br>if(n > 0) { <br>if(n <= 9) n = '0' n; <BR>return String(n); <BR>} else { <BR>return '00'; <BR>} <BR>}, <BR>run: function(){ <BR>var ts = Math.round((new Date(d).getTime() - new Date().getTime()) / 1000); <BR>if(o && ts > 0) <br>{ <br>var yy = Math.floor(ts / 31556926); <br>var mm = Math.floor(ts / 2629744); mm = mm > 0 ? mm : '00'; <br>var dd = Math.floor(ts / 86400); dd = dd > 0 ? dd0 : '00'; <br>var hh = Math.floor(ts / 3600); hh = hh > 0 ? hh$ : '00'; <br>var ii = Math.floor(ts / 60); ii = ii > 0 ? ii` : '00'; <br>var ss = Math.floor(ts % 60); <br><br>if(o.y) o.y.innerHTML = f.zero(yy); <br>if(o.m) o.m.innerHTML = f.zero(mm); <br>if(o.d) o.d.innerHTML = f.zero(dd); <br>if(o.h) o.h.innerHTML = f.zero(hh); <br>if(o.i) o.i.innerHTML = f.zero(ii); <br>if(o.s) o.s.innerHTML = f.zero(ss); <br>} <br><br>window.setTimeout(f.run,1000); <br>} <br>} <br><br>f.run(); <br>} <br><br>function ieFixed(id) <br>{ <br>var isIE = (document.all) ? true : false; <br>var isIE6 = isIE && ([/MSIE (d).0/i.exec(navigator.userAgent)][0][1] == 6); <br>var obj = document.getElementById(id).style; <br>if (isIE6 && obj) <br>{ <br>obj.position = "absolute"; <br>obj.bottom = "0px"; <br>obj.right = "0px"; <br>var tm = window.setInterval(function(){ <br>obj.marginBottom = "0px"; <br>obj.left = ( document.documentElement.scrollLeft document.documentElement.clientWidth - 312) "px"; <br>}, 80); <br>} <br>} <br></script>





<script> <br>var d = new Date().getTime() 3600*24*1000; <br>var d = 1379572933131; <br>var o = { <br>d: document.getElementById('day'), <br>h: document.getElementById('hour'), <br>i: document.getElementById('min'), <br>s: document.getElementById('sec') <br>} <br>djs(d,o);//倒计时 <br><br>ieFixed('lefttime3'); //固定在底部 <br></script>



1)兼容IE6
2)自动倒计时,输入的数字必须是时间,单位毫秒。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn