|
发表于 2007-8-7 20:31:45
|
显示全部楼层
<html>
. k7 b: f& d7 Y<head>/ |/ y; c6 z" K n2 K' f
<title>无标题文档</title>
! A) I3 g* m( U. p( y [2 Y+ A( m<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
: F8 l& J+ w; d0 B) ^<style>3 m9 L1 w' i3 u
<!--
+ k. e7 ` X% t9 y' d0 u; n7 Obody, p, div,td,input {font:menu;line-height: 150%}! h6 S1 @! _; ^
.div { font-family: 宋体; font-size: 12px; line-height: 150% }1 o! j% z/ C( F8 V* I) a& u* i9 B
-->4 f0 r$ G4 q3 }. _. `$ \* W
</style>
; d, w! C. k" O5 ~<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
8 M+ U9 @+ [3 D3 v) Z, d//创建一个数组,用于存放每个月的天数( ~5 A. ]0 V, T6 l# V; s, x( n
function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) 4 i$ d* }9 W+ `3 c3 d6 q% ~
{$ B1 o5 O7 W6 K- @5 f1 x' ~
this[0] = m0;
: A5 z2 T2 }( G7 x; Jthis[1] = m1;
6 H: C, a2 Y9 U8 A4 c ythis[2] = m2;
+ T1 \& H/ D/ R2 e2 I' vthis[3] = m3;
& p5 f, T; h; @this[4] = m4;8 _0 P5 T8 H6 y& f L! f/ B
this[5] = m5;- G% @! b+ p2 f5 q
this[6] = m6;/ e# W9 m" q" a% n
this[7] = m7;
# f' L6 _, y; _( l: x$ F, athis[8] = m8;( ~/ ~7 q1 T5 s. y% T. X
this[9] = m9;
+ q' O/ T) u* F; K5 t3 pthis[10] = m10;
* l. V9 C- j3 b4 m* Vthis[11] = m11;/ J: P7 M& c! s
}5 p W6 ? g4 l5 |' N" U( j
//实现月历) W/ u. f0 H8 _' a
function calendar() {) Y- ]4 k# n8 p8 C) c/ i
var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";
& ^+ M1 i! {# ~& ]- y1 u( S7 ~var today = new Date();- R9 L7 _& g( \6 p2 Q, x( k
var thisDay;
" T9 w( P! M2 gvar monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+ v# E. @" D3 m/ O @0 Eyear = today.getYear() +1900;
! b5 T! M( Z# }; }! C" VthisDay = today.getDate();
: M, i. E6 u. \+ U# l% L) aif (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;
& o8 w; }& R* p# ?' RnDays = monthDays[today.getMonth()];
4 {& S, k6 ?, T2 i- [7 ofirstDay = today;
; a$ Z7 `; o, S" F, }firstDay.setDate(1);, u" h ~; |3 b" m0 u
testMe = firstDay.getDate();
! w3 B1 } {0 S) l, Vif (testMe == 2) firstDay.setDate(0);6 l7 ]8 M4 }+ c
startDay = firstDay.getDay();
3 ?( s" W% o) F) F$ L& k$ |# zdocument.write("<div id='rili' style='position:absolute;width:140px;left:300px;top:100px;'>") & K0 K& E" d6 o1 @
document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>")
7 O; F6 Y7 C2 O' n1 T; hdocument.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>");
1 d$ D1 A5 `2 u. hdocument.write("<TR><th colspan='7' bgcolor='#C8E3FF'>");: [# C- f8 l z5 S2 a
var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");+ J% Z* ^; G7 h1 ~2 E
var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");* G# _& T$ y9 m" G, P% n$ O4 ^3 J
var now = new Date();
7 H( ^. }2 m1 e. w% Fdocument.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>");
* X0 K1 z# d3 m! f4 tdocument.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>");0 W! r1 D+ G$ R4 ` [, H
document.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>");
) w0 K# S* ]# O' X. f1 l7 M6 N: T4 @, `+ kdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>");( @0 B0 }: Q# z' R$ m9 b$ Z* ~
document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>");6 K5 U3 H: Z9 ^& i( ] A. q
document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>");
/ C" H5 ^* J, C5 K/ |: ldocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>");
" E- D6 e p: x4 k+ o+ ^; V8 Wdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>");( i7 A4 I" ?5 d4 }
document.writeln("</TR><TR>");- |. n! H" M1 w9 p+ S) S( f
column = 0;- d% E8 h: r6 \. C) G6 q' @" n
for (i=0; i<startDay; i++) {
3 z7 ~. T( A- s7 ~, O7 f( c1 Y: {document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>");; r( i0 g8 |0 ^( J2 L
column++;
w/ v8 W& E) b7 D" e}
6 o6 {8 i% n* K% M/ C, g$ \3 G# I3 S
for (i=1; i<=nDays; i++) { Z; P3 i4 D. T" o$ W
if (i == thisDay) {
& t, l" s% |/ ydocument.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>")
0 H! B: J+ l |8 y) C}
% ^ S) {, G3 C8 g5 H# W) \else {
5 p- y5 A; r7 R w& Cdocument.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>");
( |# L: `* n6 \5 d}1 ^* ]6 W+ x- i) [8 W* Y3 \
document.writeln(i);& C9 ?. l/ V3 t @5 Q* ~' @ C
if (i == thisDay) document.writeln("</FONT></TD>")
! w5 x# H9 `2 Z8 s: ~column++;
3 Z+ z: @% p" dif (column == 7) {
: g7 w6 B1 e% k9 ]document.writeln("<TR>"); 9 B$ z3 S' `1 e% P! c( \
column = 0;
5 I3 \4 e! t9 g& A/ H; s}
U2 ~. V5 r$ R) K}
' t+ A6 h9 d# Y# k" L v7 g# }document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>")( y$ o* v; _5 \$ R( K
document.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>")0 _4 z, D" |+ k9 H. }1 F3 A- [
document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>")
0 ^# d# X! c& p/ _" x, Q! Ddocument.writeln("</TD></TR></TABLE></div>");# J, e, p2 e/ u
}( G ~3 c" ~/ |! d- N+ D# X& C
</SCRIPT>9 J$ P) ?& P) G/ c& g2 S. A5 J# O
<SCRIPT LANGUAGE="JavaScript"># f7 Q. I% e+ M3 `% v
var timerID = null;0 o# `5 p. M2 L5 G4 c; Q: Z
var timerRunning = false;
- X- f& f4 o" h. @* E9 \! b6 b/ G+ @! x) w' U
function stopclock (){% ]6 ~( w7 [" p1 ?* a4 T" e
if(timerRunning)
, n) \9 L) y8 {/ Y. _' ?$ l; ]! bclearTimeout(timerID);) }' {5 f* n* u- b8 K S- s
timerRunning = false;}
. ?6 i# Z6 }2 }2 L6 ?6 z0 p/ `! b+ ~# m4 M1 d% T
//显示当前时间
. I) o7 y, t' @* ufunction showtime () {; V& ^6 f& n* P
var now = new Date();
6 @8 W+ D& b( T0 v9 _, Tvar hours = now.getHours();
# l3 N8 d/ J) B$ _% zvar minutes = now.getMinutes();2 ~% @' M1 p s$ Z
var seconds = now.getSeconds()# j- ^$ E' m/ y( u6 c
var timeValue = " " + ((hours >12) ? hours -12 :hours). j$ j2 R% x0 u2 d) D& {$ j
timeValue += ((minutes < 10) ? ":0" : ":") + minutes) G! H: M" w" S" z; ^
timeValue += ((seconds < 10) ? ":0" : ":") + seconds+ B& J# j/ x) S# ~
timeValue += (hours >= 12) ? " 下午 " : " 上午 "
P5 E+ L. [0 b$ l& idocument.clock.face.value = timeValue;
! B( ]9 V8 C3 H+ VtimerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示+ x6 c" W) u Z5 M/ G9 @5 @0 |
timerRunning = true;}
6 u k. l7 B' p% Y {
* I& U' O) `/ G8 N- X- B4 Y$ j9 k) x9 ~function startclock () {! w4 ?' b( s6 v" o2 x* H" T
stopclock();# W0 w }$ R9 @6 V G
showtime();}# J0 S+ Z9 z& {- l: R/ H
</SCRIPT>. H6 F% H6 t: A! c
* i3 `3 G8 A2 D8 P' H
</head>
c' K9 D5 c: p9 Y
$ P4 H+ E" Q# f1 S6 F" _& m<body bgcolor="#FFFFFF" onLoad="startclock(); timerONE=window.setTimeout"text="#000000">
$ L) N( U- N2 a, {, |& Q<script language="JavaScript" type="text/javascript">; M* @/ Z a' D. ]
<!--1 [6 r& f! M, ^0 a7 j
calendar();1 b" z( H1 N. C4 c* m/ Z
//-->' ~1 t/ k" P8 @( w: g+ U/ \
. P: Q1 e. g' _( e- N6 U</script>
' i- o% }* c @ B2 |$ w5 q* M
X2 p g( b6 a: _7 a2 y</body>
, B! r. y2 w! Q5 Z' @0 Q</html> |
|