早教吧 育儿知识 作业答案 考试题库 百科 知识分享

倒计时IENaN小时NaN分NaN秒怎么解决functionshowstudent163time(){window.setTimeout("showstudent163time()",1000);BirthDay=newDate("2014-12-24");today=newDate();timeold=(BirthDay.getTime()-today.getTime());sectimeold=timeold/1000

题目详情
倒计时IE NaN小时NaN分NaN秒怎么解决 function show_student163_time(){
window.setTimeout("show_student163_time()", 1000);
BirthDay=new Date("2014-12-24");
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML=hrsold+"小时"+minsold+"分"+seconds+"秒" ;
span_dt_dt2.innerHTML=daysold+"天";
}
show_student163_time();
▼优质解答
答案和解析
IE老版本不认识-为分隔符的日期,需要用/分隔
所以BirthDay=new Date("2014-12-24");
要改为
BirthDay=new Date("2014/12/24");