怎样在网页上显示一个计时的时间?
如题,显示的计时时间随着时间的增加而减少,到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+"天 ");}
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+"分 ");}
if (minutes != 1 && minutes < 10){minutes = ("0"+minutes+"分");}
if (minutes > 9){minutes = (minutes+"分");}
if (seconds == 1){seconds = ("0"+seconds+"秒 "+"!");}
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




