|
|
发表于 2007-8-7 20:31:45
|
显示全部楼层
<html>
6 N0 E; F1 P/ s5 x/ \) }<head>
" c9 L3 B( W2 s( k<title>无标题文档</title>
/ e! p& {0 D$ G B3 I0 g+ D<meta http-equiv="Content-Type" content="text/html; charset=gb2312">; @) u3 P6 r+ G* w5 F* j4 S
<style>
2 J" {0 V9 t& i, p& U& r0 G<!--
5 ^8 J$ H' o! P% A! _body, p, div,td,input {font:menu;line-height: 150%}
/ F; m* q" S% n( i8 W.div { font-family: 宋体; font-size: 12px; line-height: 150% }
6 W0 F m. X, t: H9 T-->
; u3 E* ?1 J) v/ A. R</style>* a( A Z9 Z. D4 }; Q# T
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">- ^ g& I, t$ E" b2 S6 V
//创建一个数组,用于存放每个月的天数
6 n6 h9 r4 B8 d3 m3 a; }function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)
* p9 Q! t/ b$ I- B{
* y7 o2 R! i c7 vthis[0] = m0;
v, | y- r( P; ethis[1] = m1;
% D/ D8 N6 \5 N5 v/ N4 w$ [this[2] = m2;
+ M+ w) T* n& ~, ^this[3] = m3;* R0 c2 c. \: N8 @2 y
this[4] = m4;
% S! ^# n. G" D7 D* ?" lthis[5] = m5;
! t" T3 `& t, U9 L* qthis[6] = m6;
( N4 _, I# G5 {! A$ L ethis[7] = m7;
) L C, |) i7 W Cthis[8] = m8;+ B' N5 Y- Y1 E- L1 e: M
this[9] = m9;4 X; A7 `3 X! Z, V) _5 J: |
this[10] = m10;
) Y [2 Q7 l" @$ Y$ t- Mthis[11] = m11;
b+ A" N( ?6 X& ^$ N9 I}/ |+ C* w$ Q7 }! k
//实现月历
- [3 _2 B2 q l0 V; _/ n pfunction calendar() {
8 ?' x1 G. ~( t* E6 j) e; kvar monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";7 m' w* i+ G, I, r8 d& V6 R
var today = new Date();1 M, v3 M$ s5 f
var thisDay;+ Q' o2 F# l4 H9 V2 `
var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
7 T. X. g* R, c& ?- Zyear = today.getYear() +1900;- v) U0 }4 I' Q. p7 b
thisDay = today.getDate();! g: B3 }" J3 P9 B4 ~* k
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;6 c# [% p$ ~( N8 J4 \3 W% ?+ R( w
nDays = monthDays[today.getMonth()];' s' J% O! N/ u: v1 ]
firstDay = today;
" ^9 l0 A; D0 U6 f" j: WfirstDay.setDate(1);3 X) ^! H A/ |
testMe = firstDay.getDate();
. Z8 ]% Y" f7 B/ dif (testMe == 2) firstDay.setDate(0);
1 m$ ]$ Z" g3 u" E5 n& v9 v& Q2 _startDay = firstDay.getDay();
* ~# ~" V6 c1 Ydocument.write("<div id='rili' style='position:absolute;width:140px;left:300px;top:100px;'>") 4 m& w9 U/ V* N
document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>")
8 V, ^1 t% v$ C5 a/ x. H( c9 Adocument.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>");
) e2 ^, N9 k# D* Z* G, z: gdocument.write("<TR><th colspan='7' bgcolor='#C8E3FF'>");" A- a# {# Z% Z& H7 D
var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
) L- z: O+ q+ ~/ A7 evar monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");4 A4 _. A5 F9 O) M6 f
var now = new Date();
0 J* D6 m2 p. y2 {/ }document.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>");! N @, w. f; o# g) h$ A
document.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>");
v+ W% ?) z5 P odocument.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>");+ \$ ^4 {0 a7 o, J& ]
document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>");
4 E" n9 r6 ~3 Sdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>");9 P2 {, j) S3 A6 O, t% e3 H% X
document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>");
9 J+ @, f! ]) u V) F( d; e7 xdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>");
& U; q9 r% ^+ Zdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>");
" Y4 r2 Q) W0 ?: xdocument.writeln("</TR><TR>");% a \ C. m; S$ B
column = 0;2 Q/ ]& K, N1 ]. Q! f7 U' R. M
for (i=0; i<startDay; i++) {- @$ O/ J& g# |8 t
document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>");% O6 `/ o8 Q) J" {
column++;
& P$ _; P8 g% f4 ~. v- y0 M}6 y+ a8 Q, \/ A$ _8 W/ D
% K% {$ D, ?" J( g$ y. x# x0 o2 ufor (i=1; i<=nDays; i++) {
; u, ?' @) B% w( eif (i == thisDay) {
* J# J9 b% t P7 K5 v, odocument.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>") \6 e7 ~/ p# S3 Z# H @
}
# R. O5 v! E% |+ @' \else {: `$ a9 p( j7 W/ [4 L5 N2 S! x
document.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>"); P8 ~& E% s, G z3 P0 U4 |
}
0 g3 ^, ]# S* t- z7 N& H! jdocument.writeln(i);
1 B6 F& d9 E8 s$ o9 b mif (i == thisDay) document.writeln("</FONT></TD>")
& D# t4 q) n: q' C k5 n# icolumn++;7 p7 n# u. [/ h0 V6 Z1 Z' y6 u
if (column == 7) {
2 O+ ]3 {. Q" b9 r/ n4 ]$ xdocument.writeln("<TR>");
G2 d; h0 J/ u4 B$ W% E- ycolumn = 0;; J. x1 R" n6 H: j; D. k) q3 F
}
/ R: Y3 x5 X6 ]+ ^5 [; ~# z}
' m% f- m2 k" n- V# L" J# Edocument.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>")
/ a5 F" D0 U+ s- B: T9 b$ n2 e8 A# Zdocument.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>")# L8 K, d6 u5 ^) V3 E" X( o
document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>")
# P2 b5 G4 f, J* T6 v, wdocument.writeln("</TD></TR></TABLE></div>");
* W& L' m/ x; R( G5 ~ P4 y7 v}) _' ^- Y( s5 |8 \
</SCRIPT>0 Y! G1 _+ x' p
<SCRIPT LANGUAGE="JavaScript">) ^* n% n# i; k
var timerID = null;
, w8 C1 P; Y ~, e4 Vvar timerRunning = false;
& X; ]) O P9 x( `
* y$ t) F" I/ Y$ c: R. wfunction stopclock (){! k& F+ ?' J1 z1 u+ j0 S
if(timerRunning)5 X$ B. K" ?# Q$ F5 q
clearTimeout(timerID);
* M9 v! t1 A4 ~4 w" S V: d6 xtimerRunning = false;}! y4 R) @9 u Z
3 g' k4 y* Q1 X4 V9 R" M9 \//显示当前时间
5 ? S, }/ R+ F0 A; Hfunction showtime () { y* Q0 K9 M+ j* M
var now = new Date();
7 A- @- s9 x% y' D4 ?8 X! O, m0 Svar hours = now.getHours();
" X5 n' ]) M, ^1 _& ?( b Uvar minutes = now.getMinutes();
& W: Z# e/ z: Mvar seconds = now.getSeconds()
3 K ~0 ]' P" K Z9 Q. u+ R) e+ fvar timeValue = " " + ((hours >12) ? hours -12 :hours)4 L+ ~9 t* ^8 l. v$ B2 A( `
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
) z( }" E% t# M1 r$ q; U# h3 ZtimeValue += ((seconds < 10) ? ":0" : ":") + seconds
9 }3 B9 {, }# P& _timeValue += (hours >= 12) ? " 下午 " : " 上午 "( ]# _" P% y' w
document.clock.face.value = timeValue;
9 n) y: t' j5 p& d) [timerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示5 y. o. ]; w" }& K/ u$ l
timerRunning = true;}
% ~2 m" z S# j3 E( _
O) K, D: V. ^! O( N. L4 u! \function startclock () {4 t& @' [4 y, [0 d
stopclock();% b8 t) S* s/ w/ f: o( b4 D
showtime();}
, @/ x& k8 d. ], k5 q- D v</SCRIPT>' |+ X; [* {: o* e. F/ Z/ @3 W, K
U/ J0 B2 K- W# m6 t</head> ]" V$ i# P ^& L9 v) @! ]7 Z
- h: K3 Y3 e# N1 _ W) k. a<body bgcolor="#FFFFFF" onLoad="startclock(); timerONE=window.setTimeout"text="#000000">5 B$ i, {( `+ U9 h
<script language="JavaScript" type="text/javascript">
- H" v5 F `, G; b<!--
* A7 X! F" O& {3 hcalendar();0 K/ U, {6 Q6 Y0 ]
//-->2 h9 |% z; D; _: D, L: Z
+ \8 \0 H8 q: X2 p
</script>( t! W+ V5 a8 z
; D( y9 _3 f7 t
</body>6 P2 f% z* w3 i8 ^& L3 a
</html> |
|