日期:2014-05-16 浏览次数:20418 次
var interval = 1000;
function offerclickShowCountDown(year,month,day,h,i,s,divname){
var now = new Date();
var endDate = new Date(year, month-1, day,h,i,s);
var leftTime=endDate.getTime()-now.getTime();
if(leftTime<=0){
location.reload();
}
var leftsecond = parseInt(leftTime/1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
var cc = document.getElementById(divname);
cc.innerHTML = "<span>"+hour+"</span>小时<span>"+minute+"</span>分<span>"+second+"</span>秒后可继续该任务";
}
<{if $nextruncate_ts!=''}>
window.setInterval(function(){offerclickShowCountDown('<{$nextruncate_ts.exceed_ts_y}>','<{$nextruncate_ts.exceed_ts_m}>','<{$nextruncate_ts.exceed_ts_d}>','<{$nextruncate_ts.exceed_ts_H}>','<{$nextruncate_ts.exceed_ts_i}>','<{$nextruncate_ts.exceed_ts_s}>','offerclickunix');}, interval);
<{/if}>
<!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>
<SCRIPT LANGUAGE="JavaScript">
<!--
var maxtime = 15*60 //一个小时,按秒计算,自己调整!
function CountDown(){
if(maxtime>=0){
hours=Math.floor(maxtime/3600);
minutes = Math.floor(maxtime/60)-hours*60;
seconds = Math.floor(maxtime%60);
msg = "距离结束还有"+hours+"小时"+minutes+"分"+seconds+"秒";
document.all["timer"].innerHTML=msg;
if(maxtime == 5*60) alert('注意,还有5分钟!');
--maxtime;
}
else{
clearInterval(timer);
alert("时间到,结束!");
}
}
timer = setInterval("CountDown()",1000);
//-->
</SCRIPT>
</head>
<body>
<div id="timer" style="color:red" mce_style="color:red"></div>
</body>
</html>