我已经搜索过网络,但所有现成的网站都是您特定日期的地方,并且计算到那个日期.我需要的是从"27分43秒"(以这种格式)从它们落在页面上一直到0的状态简单倒计时,任何人都可以获得任何片段?
这样的事情应该可以解决问题.我很无聊,决定自己做而不是谷歌搜索.只需将分钟和秒设置在顶部,然后将onload中的倒计时调用更改为要更新的元素的id.
我做了一个简单的倒计时你可以使用.
它正在生成以下格式:
DAYS X,HOURS X,MINUTES X,SECONDS X.
JS:
countIt(); function countIt(){ year = 2013; month = 05; day = 28; hours = 12; minutes = 00; seconds = 00; setTimeout(function(){ endDate = new Date(year, (month - 1), day, hours, minutes, seconds, 00); thisDate = new Date(); thisDate = new Date(thisDate.getFullYear(), thisDate.getMonth(), thisDate.getDate(), thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds(), 00, 00); var daysLeft = parseInt((endDate-thisDate)/86400000); var hoursLeft = parseInt((endDate-thisDate)/3600000); var minutsLeft = parseInt((endDate-thisDate)/60000); var secondsLeft = parseInt((endDate-thisDate)/1000); seconds = minutsLeft*60; seconds = secondsLeft-seconds; minutes = hoursLeft*60; minutes = minutsLeft-minutes; hours = daysLeft*24; hours = (hoursLeft-hours) < 0 ? 0 : hoursLeft-hours; days = daysLeft; startCount(days, hours, minutes,seconds); }, 1000); } function startCount(days, hours, minutes, seconds){ document.getElementById("counter").innerHTML="DAYS "+days+", HOURS "+hours+", MINUTES "+minutes+", SECONDS: "+seconds; countIt(); }
HTML:
点击这里观看直播