之前做的活动页面很多都用到了倒计时功能,所以整理下下次直接用。
(用的是张鑫旭写的一个倒计时,稍作修改了下,原文:?p=987)
用法:
<div> <span>00</span>: <span>00</span>: <span>00</span>: <span>00</span>: <span>00</span>: <span>00</span> </div> <script type="text/javascript"> // 获取本机当前时间 var mydate = new Date(); // console.log(mydate.getFullYear(), parseInt(mydate.getMonth())+1, mydate.getDate(), mydate.getHours(), mydate.getMinutes(), mydate.getSeconds()); var futureDate = eval(Date.UTC(2014, 10, 30, 12, 0, 0)); // var nowDate = eval(Date.UTC(2013, 11, 15, 16, 36, 52)); var nowDate = eval(Date.UTC(mydate.getFullYear(), parseInt(mydate.getMonth())+1, mydate.getDate(), mydate.getHours(), mydate.getMinutes(), mydate.getSeconds())); var obj = { sec: document.getElementById("seconds"), mini: document.getElementById("minutes"), hour: document.getElementById("hours"), day: document.getElementById("days"), day: document.getElementById("months"), day: document.getElementById("years") } fnTimeCountDown(futureDate, obj, nowDate, function () { // console.log(\'时间到了!\'); }); </script>