| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6902 人关注过本帖, 2 人收藏
标题:请问如何用ASP实现时间倒计时?
只看楼主 加入收藏
pcrr100530
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-7-6
收藏(2)
 问题点数:0 回复次数:7 
请问如何用ASP实现时间倒计时?
本人要做一个时间倒计时器,要求
1、在页面上实现3分钟的倒计时。
2、按分、秒显示剩余时间。
3、页面上添加“复位”按钮重新倒计时


辛苦大家了!!
搜索更多相关主题的帖子: ASP 倒计时 时间 
2007-07-06 16:40
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 

[CODE]<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>
</table>
<!-- end calendar -->
</div>
</BODY>
</HTML>[/CODE]

参考一下这个。

2007-07-06 17:26
pcrr100530
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-7-6
收藏
得分:0 

谢谢啊!

2007-07-09 21:55
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
[CODE]<html>
<title>倒计时关闭网页</title>
<head>
<script language="javascript">
var cTime=100;
function TimeClose()
{
window.setTimeout('TimeClose()',1000);
if(cTime<=0)
CloseWindow_Click();
this.ShowTime.innerHTML="倒计时"+cTime+"秒后关闭当前窗口";
cTime--;
}
function CloseWindow_Click()
{
window.close();
}
</script>
</head>
<body onLoad="TimeClose();">
<div id="ShowTime">倒计时100秒后关闭当前窗口</div>
<input type="button" name="CloseWindow" onClick="CloseWindow_Click();" value="立即关闭当前网页">
</body>
</html>[/CODE]
以前写的楼主可以参考一下。
2007-07-10 10:44
qhscqb
Rank: 1
等 级:新手上路
威 望:1
帖 子:343
专家分:0
注 册:2007-2-3
收藏
得分:0 


在下答非所问!
这个段代码也挺有意思



nTktIEKx.txt (391 Bytes) 请问如何用ASP实现时间倒计时?



编程快乐,快乐编程! 没有最好,只有更好!
2007-07-10 13:46
pcrr100530
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-7-6
收藏
得分:0 
回复:(yms123)[CODE]倒计...

谢谢啊!

2007-07-20 14:29
pcrr100530
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-7-6
收藏
得分:0 
回复:(yms123)[CODE]倒计...
谢谢
2007-07-20 14:29
dyx06120204
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-11-12
收藏
得分:0 
谢谢啦
2008-11-12 12:10
快速回复:请问如何用ASP实现时间倒计时?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016925 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved