js 模仿网上的限时抢购效果
抢购时间倒计时效果
function $(element){
return document.getElementById(element);
}
//限时抢购
var the_s=new Array();
function view_time(the_s_index,objid){
if(the_s[the_s_index]>=0){
var the_D=Math.floor((the_s[the_s_index]/3600)/24)
var the_H=Math.floor((the_s[the_s_index]-the_D*24*3600)/3600);
var the_M=Math.floor((the_s[the_s_index]-the_D*24*3600-the_H*3600)/60);
var the_S=(the_s[the_s_index]-the_H*3600)%60;
html = "还剩 ";
//if(the_D!=0) html += the_D+"天";
if(the_D!=0 || the_H!=0) html += ''+(the_H+(the_D*24))+"小时";
if(the_D!=0 || the_H!=0 || the_M!=0) html += ''+the_M+"分";
html += ''+the_S+"秒";
$(objid).innerHTML = html;
the_s[the_s_index]--;
}else{
$(objid).innerHTML = "已结束";
}
}
还剩 14小时49分44秒
var startDate= new Date("2010/07/16 09:07:43");
var endDate= new Date("2010/07/17 00:00:00");
the_s[2402]=(endDate.getTime()-startDate.getTime())/1000;
setInterval("view_time(2402,'xsq_2402')",1000);
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]