<!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 content="text/html; charset=UTF-8" http-equiv="Content-Type"/> <title>Javascript完整的倒计时应用代码——物联网技术资讯互动平台</title> <meta name="description" content="物联网技术资讯互动平台——为物联网产业发展搭建技术互动平台;传播全球物联网技术发展动态和趋势;推广物联网行业新产品与新方案;促进物联网技术的创新、交流与繁荣。" /> <meta name="keywords" content="物联网技术,物联网资讯,物联网平台" /> <meta content="IE=7" http-equiv="X-UA-Compatible"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.js" type="text/javascript"></script> </head> <body> <span id="Lasttime" ></span> </body> </html> <script language="javascript" type="text/javascript"> var NowTime = new Date(2011,5-1,8,9,29,22); //当前时间 var EndTime= new Date(2011,5-1,8,20, 0,0); //截止时间 var DiffTime = NowTime.getTime() - (new Date()).getTime(); var RemainD = '天'; var RemainH = '小时'; var RemainM = '分'; var RemainS = '秒'; function GetRTime(){ NowTime = new Date(); var nMS = EndTime.getTime()- (NowTime.getTime() + DiffTime); var nD = Math.floor(nMS/(1000 * 60 * 60 * 24)); var nH = Math.floor(nMS/(1000*60*60)) % 24; var nM = Math.floor(nMS/(1000*60)) % 60; var nS = Math.floor(nMS/1000) % 60; var nMS = Math.floor(nMS/100) % 10; var s = ""; if(nD > 0) { s += nD + RemainD; } if(nH > 0) { s += nH + RemainH; } if(nM > 0) { s += nM + RemainM; } if(nS > 9) { s += nS + RemainS; } else if(nS >0) { s += "0" + nS + RemainS; } else { s += "00" + RemainS; } if(nD<=0 && nH<=0 && nM<=0 && nS<=0) { $("#Lasttime").html("已经结束").addClass("red"); return; } else if(nD>0) { $("#Lasttime").html(nD + RemainD+nH + RemainH); } else if(nD<=0&&nH>1) { $("#Lasttime").html(s); } else if(nD<=0&&nH<1&&nS>0&&nM>30) { $("#Lasttime").html(s); } else if(nD<=0&&nH<1&&nM<30) { $("#Lasttime").html(s).addClass("red"); } setTimeout("GetRTime()",1000); } var mkstate=0; if(0!=1) { if(mkstate==0) { document.οnlοad=GetRTime(); } else { $("#Lasttime").html("已经结束").addClass("red"); } } else { $("#Lasttime").html("不受限制"); } </script>
Javascript完整的倒计时应用代码
最新推荐文章于 2021-03-19 14:55:25 发布