<div id="TimeCounter" style="border:1px solid black;margin:1px;padding:2px;300px"></div> <SCRIPT language=javascript> <!-- function show_date_time(){ window.setTimeout("show_date_time()", 1000); target=new Date(2008,8,8,20,00,00); 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.getElementByIdx_x_x("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<3) { document.getElementByIdx_x_x("TimeCounter").innerHTML="离奥运会开幕还有"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒"; } else document.getElementByIdx_x_x("TimeCounter").innerHTML="离奥运会开幕还有" + daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒"; } } show_date_time(); //--> </SCRIPT></div> ***************************到某个时间自动转向另一个页面*************************************** <span id="span_dt_dt" style='border:1px solid black;background-color:#FFFFFF' ></span> <script language=javascript> <!-- function show_student163_time(){ window.setTimeout("show_student163_time()", 1000); BirthDay=new Date("2010/11/02 11:55:00");//改成你的计时日期 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); if(daysold>=0&&hrsold>=0&&minsold>=0&&seconds>0) { span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ; } else { location.href="http://www.baidu.com/"; } } show_student163_time(); //--> </script>