日期:2014-05-17  浏览次数:20490 次

【javascript】倒计时问题 【火狐浏览器】没有支持【怎么修改】
由于本人JS不好。所以JS写得笨了些。希望高手指教
JScript code

 <script language="JavaScript"> 
function ShowTimes(){ 
var AfterTime= new Date("12-11-2012 14:00:00"); //这里是北京上市会时间
LeaveTime = AfterTime - new Date(); 
var ne = document.getElementById("dh"); 
if(0 >= LeaveTime){
    clearInterval(id);
    ne.innerHTML="已开始";
    return false;
}
LeaveDays=Math.floor(LeaveTime/(1000*60*60*24)); 
LeaveHours=Math.floor(LeaveTime/(1000*60*60)%24); 
LeaveMinutes=Math.floor(LeaveTime/(1000*60)%60); 
LeaveSeconds=Math.floor(LeaveTime/1000%60); 
var c=new Date(); 
var q=c.getMilliseconds(); 
ne.innerHTML="距<font color=red>北京上市会</font>还有<font color=red>"
+LeaveDays+"</font>天 <font color=red>"
+LeaveHours+"</font>时 <font color=red>"
+LeaveMinutes+"</font>分 <font color=red>"
+LeaveSeconds+"</font>秒 <font color=red>"
+q+"</font>";
}
var id = setInterval(ShowTimes,10); 
</script>


 <script language="JavaScript"> 
function ShowTimesh(){ 
var AfterTimes= new Date("12-12-2012 14:00:00"); //这里是上海上市会时间
LeaveTimes = AfterTimes - new Date(); 
var ne = document.getElementById("sh"); 
if(0 >= LeaveTimes){
    clearInterval(id);
    ne.innerHTML="已开始";
    return false;
}
LeaveDays=Math.floor(LeaveTimes/(1000*60*60*24)); 
LeaveHours=Math.floor(LeaveTimes/(1000*60*60)%24); 
LeaveMinutes=Math.floor(LeaveTimes/(1000*60)%60); 
LeaveSeconds=Math.floor(LeaveTimes/1000%60); 
var c=new Date(); 
var q=c.getMilliseconds(); 
ne.innerHTML="距<font color=red>上海上市会</font>还有<font color=red>"
+LeaveDays+"</font>天 <font color=red>"
+LeaveHours+"</font>时 <font color=red>"
+LeaveMinutes+"</font>分 <font color=red>"
+LeaveSeconds+"</font>秒 <font color=red>"
+q+"</font>";
}
var id = setInterval(ShowTimesh,10); 
</script>





 <script language="JavaScript"> 
function ShowTimesh(){ 
var AfterTimes= new Date("12-13-2012 14:00:00"); //这里是广州上市会时间
LeaveTimes = AfterTimes - new Date(); 
var ne = document.getElementById("gz"); 
if(0 >= LeaveTimes){
    clearInterval(id);
    ne.innerHTML="已开始";
    return false;
}
LeaveDays=Math.floor(LeaveTimes/(1000*60*60*24)); 
LeaveHours=Math.floor(LeaveTimes/(1000*60*60)%24); 
LeaveMinutes=Math.floor(LeaveTimes/(1000*60)%60); 
LeaveSeconds=Math.floor(LeaveTimes/1000%60); 
var c=new Date(); 
var q=c.getMilliseconds(); 
ne.innerHTML="距<font color=red>广州上市会</font>还有<font color=red>"
+LeaveDays+"</font>天 <font color=red>"
+LeaveHours+"</font>时 <font color=red>"
+LeaveMinutes+"</font>分 <font color=red>"
+LeaveSeconds+"</font>秒 <font color=red>"
+q+"</font>";
}
var id = setInterval(ShowTimesh,10); 
</script>



<span id="dh" style="padding-left:220px;margin:5px;color:#000000; font-size:18px;" ></span>
<br/>

<span id="sh" style="padding-left:220px;margin:5px;color:#000000; font-size:18px;" ></span>
<br/>
<span id="gz" style="padding-left:220px;margin:5px;color:#000000; font-size:18px;" ></span>




------解决方案--------------------
HTML code
<!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>
<title>azhon