当前位置: 代码迷 >> JavaScript >> javascript做浮动倒数计时器-小虾快来
  详细解决方案

javascript做浮动倒数计时器-小虾快来

热度:180   发布时间:2012-03-08 13:30:13.0
javascript做浮动倒数计时器--大虾小虾快来啊
时间可以自己设置,高手请指教!!!

------解决方案--------------------
<html>
<head>
<title> 倒计时 </title>
<style>
.time{color:#ffffff;font-family:verdana,geneva,helveticafont-size:9pt}
a:link{text-decoration:none;color:#000000}
a:active{text-decoration:none;color:#000000}
a:visited{text-decoration:none;color:#000000}
a:hover{text-decoration:none;color:#000000}
</style>

<script language= "javascript ">

var time_now_server,time_now_client,time_end,time_server_client,timerID;

time_end=new Date( "Jan 20, 2002 00:00:00 ");
time_end=time_end.getTime();


time_now_server=new Date( "Dec 21, 2001 13:11:1 ");
time_now_server=time_now_server.getTime();

time_now_client=new Date();
time_now_client=time_now_client.getTime();

time_server_client=time_now_server-time_now_client;

setTimeout( "show_time() ",1000);

function show_time()
{
timer.innerHTML =time_server_client;

var time_now,time_distance,str_time;
var int_day,int_hour,int_minute,int_second;
var time_now=new Date();
time_now=time_now.getTime()+time_server_client;
time_distance=time_end-time_now;
if(time_distance> 0)
{
int_day=Math.floor(time_distance/86400000)
time_distance-=int_day*86400000;
int_hour=Math.floor(time_distance/3600000)
time_distance-=int_hour*3600000;
int_minute=Math.floor(time_distance/60000)
time_distance-=int_minute*60000;
int_second=Math.floor(time_distance/1000)

if(int_hour <10)
int_hour= "0 "+int_hour;
if(int_minute <10)
int_minute= "0 "+int_minute;
if(int_second <10)
int_second= "0 "+int_second;
str_time= " <font style= 'font-size:14pt;color:#28C84A '> "+int_day+ " </font> <font face= '黑体 ' style= 'font-size:13pt; '> 天 </font> <br> "+int_hour+ ": "+int_minute+ ": "+int_second;
timer.innerHTML=str_time;
setTimeout( "show_time() ",1000);
}
else
{
timer.innerHTML = "over ";
clearTimeout(timerID)
}
}
</script>
<style>
.time{color:#000000;font-family:verdana;font-size:9pt}
</style>
</head>

<BODY BGCOLOR=#FFFFFF topmargin=2 leftmargin=2>
<div id= "Layer1 " style= "position:absolute; width:160px; height:187px; z-index:1 ">
<!-- begin calendar -->
<table width=160 border=0 cellpadding=0 cellspacing=0>
<tr>
<td colspan=3> </td>
</tr>
<tr>
<td width= "47 "> </td>
<td background= "images/mail_03.gif " width= "67 " valign= "top ">
<table width=65 cellpadding=3 cellspacing=0 border=0>
<tr>
<td align=center class= "time ">
<a href= "http://203.212.7.76:8000/Announcement.html " target=_blank> <div id= "timer " style= "font-size:9pt;color:red "> </div> </a>
</td>
</tr>
</table>
</td>
<td width= "46 "> </td>
</tr>
<tr>
<td colspan=3> </td>
</tr>
  相关解决方案