CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

怎样在网页上显示一个计时的时间?

楼主lygztm(Zhengtm)2005-01-04 18:29:28 在 .NET技术 / ASP.NET 提问

如题,显示的计时时间随着时间的增加而减少,到0时停止!  
  我是用C#写的代码,请兄弟们指教,谢谢先!! 问题点数:0、回复次数:7Top

1 楼lygztm(Zhengtm)回复于 2005-01-04 19:16:52 得分 0

难道没人知道吗?Top

2 楼buyifly(冬雷物语)回复于 2005-01-04 20:24:29 得分 0

到JAVASCRIPT里问问应该有答案!Top

3 楼Truly()回复于 2005-01-04 20:49:52 得分 0

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN">  
  <HTML><HEAD>  
  <style>  
  <!--  
  SPAN   {font-size:   12;   font-weight:   bold}  
  -->  
  </style>  
  </HEAD>  
  <BODY   BGCOLOR="EFEFEF"   TEXT="000000"   LINK="0000FF"   ALINK="EFEFEF"   VLINK="FF0000"   onLoad="clock()">  
  <CENTER><TABLE   BORDER=1   BORDERCOLOR="RED"><TR><TD   ALIGN=CENTER   ><SPAN   id="Clock"></SPAN></TD></TR></TABLE>  
  <SCRIPT   LANGUAGE="JavaScript"><!--  
  function   clock()   {  
  if   (!document.layers   &&   !document.all)   return;  
      today   =   new   Date();  
      intDate   =   today.getDate();  
      intHours   =   today.getHours();  
      intMinutes   =   today.getMinutes();  
      intSeconds   =   today.getSeconds();  
      intMonth   =   today.getMonth()+1   ;  
      intYear   =   today.getYear();  
      hours   =   intHours;  
      hours   =   (23   -   hours);  
      minutes   =   intMinutes;  
      minutes   =   (59   -   minutes);  
      seconds   =   intSeconds;  
      seconds   =   (59   -   seconds);  
   
  if   (intYear   %   4   ==   0   &&   intYear   %   100   !=   0   ||   intYear   %   400   ==   0)  
  {   if   (intMonth   ==   1)     {month   =   "距圣诞节还有";   date   =   (359   -   intDate);}  
      if   (intMonth   ==   2)     {month   =   "距圣诞节还有";   date   =   (328   -   intDate);}  
  }  
  else  
  {   if   (intMonth   ==   1)     {month   =   "距圣诞节还有";   date   =   (358   -   intDate);}  
      if   (intMonth   ==   2)     {month   =   "距圣诞节还有";   date   =   (327   -   intDate);}  
  }  
   
      if   (intMonth   ==   3)     {month   =   "距圣诞节还有";   date   =   (299   -   intDate);}  
      if   (intMonth   ==   4)     {month   =   "距圣诞节还有";   date   =   (268   -   intDate);}  
      if   (intMonth   ==   5)     {month   =   "距圣诞节还有";   date   =   (238   -   intDate);}  
      if   (intMonth   ==   6)     {month   =   "距圣诞节还有";   date   =   (207   -   intDate);}  
      if   (intMonth   ==   7)     {month   =   "距圣诞节还有";   date   =   (177   -   intDate);}  
      if   (intMonth   ==   8)     {month   =   "距圣诞节还有";   date   =   (146   -   intDate);}  
      if   (intMonth   ==   9)     {month   =   "距圣诞节还有";   date   =   (115   -   intDate);}  
      if   (intMonth   ==   10)   {month   =   "距圣诞节还有";   date   =   (85   -   intDate);}  
      if   (intMonth   ==   11)   {month   =   "距圣诞节还有";   date   =   (54   -   intDate);}  
      if   (intMonth   ==   12)   {month   =   "距圣诞节还有";   date   =   (24   -   intDate);}  
   
      if   (date   ==   1   ){date   =   ("0"+date+"天&nbsp;   ");}  
      if   (date   !=   1   &&   date   <   10   &&   date   >=0){date   =   ("0"+date+"天");}  
      if   (date   >   9){date   =   (date+"天");}  
   
      if   (hours   ==1   ){hours   =   ("0"+hours+"小时");}  
      if   (hours   !=   1   &&   hours   <   10){hours   =   ("0"+hours+"小时");}  
      if   (hours   >   9){hours   =   (hours+"小时");}  
   
      if   (minutes   ==   1){minutes   =   ("0"+minutes+"分&nbsp;   ");}  
      if   (minutes   !=   1   &&   minutes   <   10){minutes   =   ("0"+minutes+"分");}  
      if   (minutes   >   9){minutes   =   (minutes+"分");}  
   
      if   (seconds   ==   1){seconds   =   ("0"+seconds+"秒&nbsp;"+"!");}  
      if   (seconds   !=   1   &&   seconds   <   10){seconds   =   ("0"+seconds+"秒!");}  
      if   (seconds   >   9){seconds   =   (seconds+"秒!");}  
   
      if   (date   <   0){month   =   "Merry   ";date   =   "   Christmas!   ";hours   =   "   圣诞";minutes   =   "快乐";seconds   =   "!";}  
      timeString   =   month+date+hours+minutes+seconds;  
   
   
  if   (document.layers)   {  
  document.layers.Clock.document.write(timeString);  
  document.layers.Clock.document.close();  
  }  
  else  
  if   (document.all)  
  Clock.innerHTML   =   timeString;  
  setTimeout("clock()",   1000);  
  }  
  //--></script></BODY></HTML>Top

4 楼lygztm(Zhengtm)回复于 2005-01-05 14:21:49 得分 0

用C#做不到吗?Top

5 楼lygztm(Zhengtm)回复于 2005-01-06 18:16:21 得分 0

各位大哥,帮帮忙啊!!Top

6 楼welshem(天堂客)回复于 2005-01-06 18:18:12 得分 0

在客户端运行的,用C#?  
  你有没有分清服务器端与客户端的区别啊Top

7 楼welshem(天堂客)回复于 2005-01-06 18:22:55 得分 0

<html>  
  <head>  
  <title>示例</title>  
  <script>  
  var   i=<%=初始值   %>  
  function   tick()  
  {  
          Disp.innerHTML   =   "还有"+(i--)+"秒";  
          window.setTimeout("tick();",   100);  
  }  
  window.onload   =   tick;  
  </script>  
  </head>  
  <body>  
  <div   id="Disp"   align="center"   style="font-size:   20;   color:#000000"></div>  
  </body>  
  </html>Top

相关问题

  • 如何用Javascript编一个在网页中显示倒计时的程序?
  • C++ 中计时器及时间动态显示的问题
  • 如何能在网页中显示服务器端的时间?
  • 怎样实现动态时间显示,在网页上
  • 网页不显示?
  • 在网页上显示的时间如何改用服务器的时间?
  • 如何在网页中动态显示当前的系统日期和时间?
  • 简单的问题--网页中时间(Date)显示问题--在线等
  • 怎样让javascript显示出的时间选择菜单显示在网页的最前?
  • ASP.NET2.0 里面 在网页里 如何显示始终显示当前系统时间

关键词

  • c#

得分解答快速导航

  • 帖主:lygztm

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo