<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_client,time_end,time_server_client,timerID;time_end=new Date();
time_end=time_end.getTime() + 60000*100; //20分钟
time_now_client=new Date();
time_now_client=time_now_client.getTime();setTimeout("show_time()",1000);function show_time()
{
timer.innerHTML =time_server_client; var time_now,time_distance,str_time;
var int_hour,int_minute,int_second;
var time_now=new Date();
time_now=time_now.getTime();
time_distance=time_end-time_now;
if(time_distance>0)
{
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=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>
</table>
<!-- end calendar -->
</div>
</BODY>
</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_client,time_end,time_server_client,timerID;time_end=new Date();
time_end=time_end.getTime() + 60000*100; //20分钟
time_now_client=new Date();
time_now_client=time_now_client.getTime();setTimeout("show_time()",1000);function show_time()
{
timer.innerHTML =time_server_client; var time_now,time_distance,str_time;
var int_hour,int_minute,int_second;
var time_now=new Date();
time_now=time_now.getTime();
time_distance=time_end-time_now;
if(time_distance>0)
{
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=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>
</table>
<!-- end calendar -->
</div>
</BODY>
</HTML>
解决方案 »
- 纯JS实现年月日的三级联动
- 如何去掉JavaScript下的超链接?
- 能不能将下面的正则表达式合成一个?
- <select id="test11" name="test11" childid="zzs">如何能取出zzs值呢?
- 静态页面中可变部分是用shtml好还是js好
- 在showModalDialog窗口内怎么跳转
- ajax操作中,缓存的xml文件问题
- 菜鸟问题,请帮忙!在线等待!
- 如何能查看到通过document.writeln("")写出来的html?
- 急急急!一个弱问题!!!如何在js中实现一个拼起来的http请求?
- 简单问题,请帮忙呀!
- 这里有一段实现日历选择的JS代码,但我不知道如何调用,请大家指教
<script language=javascript>
//特别注明:北京时间是格林尼治标准时加八小时,因此我用的起始时间也是从八点起算的
var secondServer = <%=DateDiff("s", "1970-01-01 08:00:00", Now())%>;
var secondClient = parseInt(new Date().getTime()/1000);
var secondSub = secondServer - secondClient; //两端时间秒差
function meizzTime(n)
{
var mei = new Date();
mei.setTime(mei.getTime() + n*1000); //得到一个新的时间
var h = (mei.getHours() > 9) ? mei.getHours() : "0" + mei.getHours();
var m = (mei.getMinutes() > 9) ? mei.getMinutes() : "0" + mei.getMinutes();
var s = (mei.getSeconds() > 9) ? mei.getSeconds() : "0" + mei.getSeconds();
document.meizz.clock.value = h +":"+ m +":"+ s;
setTimeout("meizzTime(secondSub)", 1000);
}
</script>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta http-equiv="refresh" content="100">
<title>取服务器端时间(秒数)</title>
</head><body onload="meizzTime(secondSub)">
<form name=meizz><input name=clock size=8></form>
</body></html>这段代码是得到服务器端时间的一个例子, 楼主可以将它放到页面里的一个隐藏 iframe 去,这个页面以100秒自动与服务器校对一次(刷新时间楼主可自定), 得到服务器端时间后再写到 parent 页面上去.
呵啊, meizz(梅花雨) ,真是太好了,收藏备用!!!
<html>
<head>
<script>
var counter = 20
var interval_id = setInterval("countdown()", 1000)
function countdown()
{
status = counter--
if(counter < 0)
{
clearInterval(interval_id)
status = ""
}
}
</script>
</head><body>
look downwards!
<br>
the number is count down in the status bar
</body>
</html>