Jul
11

网页倒计时代码
23:08 | 来源: 原创
效果同本图演示
修改
<div>距2008北京奥运倒计时:</div>为你自己想要的文字
target=new Date(2008,7,8,20,0,0) 时间格式是 年,月,日,时,分,秒,月份必须提前一个月,不知道为什么,反正和JAVA有关
if (daysold<30) 设置成30就在倒计时剩余30天内,字体变成红色
target=new Date(2008,7,8,20,0,0) 时间格式是 年,月,日,时,分,秒,月份必须提前一个月,不知道为什么,反正和JAVA有关
if (daysold<30) 设置成30就在倒计时剩余30天内,字体变成红色
下面是源代码
<div>距2008北京奥运倒计时:</div>
<div align=right>
<div id="TimeCounter" style="border:1px solid #e8e8e8;margin:0px;padding-right:3px;width:135px"></div>
<SCRIPT language=javascript>
<!--
//document.write("");
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
target=new Date(2008,7,8,20,0,0);
today=new Date();
timeold=(target.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);
if (daysold<0) {
document.getElementById("TimeCounter").innerHTML="逾期,倒计时已经失效";
}
else{
if (daysold<10) {daysold="0"+daysold}
if (daysold<100) {daysold="0"+daysold}
if (hrsold<10) {hrsold="0"+hrsold}
if (minsold<10) {minsold="0"+minsold}
if (seconds<10) {seconds="0"+seconds}
if (daysold<30) {
document.getElementById("TimeCounter").innerHTML="<font color=red>"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒</font& gt;";
}
else
document.getElementById("TimeCounter").innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";
}
}
show_date_time();
//-->
</SCRIPT>
</div>
<div align=right>
<div id="TimeCounter" style="border:1px solid #e8e8e8;margin:0px;padding-right:3px;width:135px"></div>
<SCRIPT language=javascript>
<!--
//document.write("");
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
target=new Date(2008,7,8,20,0,0);
today=new Date();
timeold=(target.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);
if (daysold<0) {
document.getElementById("TimeCounter").innerHTML="逾期,倒计时已经失效";
}
else{
if (daysold<10) {daysold="0"+daysold}
if (daysold<100) {daysold="0"+daysold}
if (hrsold<10) {hrsold="0"+hrsold}
if (minsold<10) {minsold="0"+minsold}
if (seconds<10) {seconds="0"+seconds}
if (daysold<30) {
document.getElementById("TimeCounter").innerHTML="<font color=red>"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒</font& gt;";
}
else
document.getElementById("TimeCounter").innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";
}
}
show_date_time();
//-->
</SCRIPT>
</div>

Google免费企业邮局
病态。。




