|
|
发表于 2007-8-7 20:31:45
|
显示全部楼层
<html>
8 A+ h6 Z9 q5 _; _; I Q3 Z; n6 G<head>
! ^) I" \; _$ v. v2 X<title>无标题文档</title>7 f1 Z. B; D4 O! a. H8 x+ V* \
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
+ J" k- l+ e2 Y3 @<style>
/ W3 V, H1 J. K<!--1 V9 {8 I0 x) A. L- }
body, p, div,td,input {font:menu;line-height: 150%}
4 E$ q6 b9 \- X- L# s.div { font-family: 宋体; font-size: 12px; line-height: 150% }
- _( H! p0 R! M" j-->
$ \' q& j/ l* G5 `0 d) n3 j</style>$ p# o6 e0 b# L* \; s. K$ }: }& G
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
- C/ w. ]% B# N% M//创建一个数组,用于存放每个月的天数" d7 @( }: n( \5 I" P! w( d
function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)
; M4 P# `! V4 p/ m3 M{) i9 X1 \. Y$ K) @0 i$ C" j$ L
this[0] = m0;
. c7 R% q1 y3 O4 tthis[1] = m1;
% O. M! v% t& B& h. |& [2 lthis[2] = m2;
0 q/ O2 [5 P4 H: h( s- s, O. gthis[3] = m3;0 O; [; E7 e2 X5 ~* V& k% B
this[4] = m4;
! u# x, {; d% Q4 d0 K. a7 othis[5] = m5;- _, b* o! u' |% p3 k
this[6] = m6;5 P, p+ l8 @. z; z9 Y! h% L0 z
this[7] = m7;9 K; t* n9 Z& P! P6 |5 j# k: r
this[8] = m8;5 g6 M$ F1 n% G& P% D8 L$ B
this[9] = m9;" x# ~0 Q$ L- S- W# _) I3 m
this[10] = m10;
0 t, U% q* Y3 m Nthis[11] = m11;
! N% I* F! B; w( W7 L9 p% e}
0 Z9 T" r, S* o0 N$ X( v//实现月历
$ E/ P6 F, L2 Sfunction calendar() {; M# ^! p3 E; u* k$ e4 e
var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";# y* w% [5 P! M2 j! d
var today = new Date();
+ Y4 w2 n! H9 p6 ~7 H* \var thisDay;; F5 P3 _3 W. J8 `8 q s1 D# M
var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
5 y: f/ G( h5 N, byear = today.getYear() +1900;
8 l% G9 X/ S4 i( W3 fthisDay = today.getDate();, Z+ w4 O1 h5 l
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;; t+ J9 [8 H" d; O% s
nDays = monthDays[today.getMonth()];
& i9 O) p$ [7 E- l5 zfirstDay = today;
. {$ Q8 Q$ p$ u% q. yfirstDay.setDate(1);
1 S1 t7 p$ d6 m# YtestMe = firstDay.getDate();
' K$ a2 ^! e0 E0 i% p4 N4 s8 bif (testMe == 2) firstDay.setDate(0);
- j' O3 d8 [/ o9 `4 [startDay = firstDay.getDay();+ i# U. I# b3 X8 H. Q5 Z
document.write("<div id='rili' style='position:absolute;width:140px;left:300px;top:100px;'>")
$ X. W, E" W% a, V- R Gdocument.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>")
9 K2 }3 k2 X k! V; h4 d5 P2 h: y2 ndocument.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>");* Q+ v3 A" M$ m* y
document.write("<TR><th colspan='7' bgcolor='#C8E3FF'>");
8 e* g$ U- D' B( q2 N+ U1 R) qvar dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");$ M3 ?- H1 U# Z% T
var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");3 a1 _& @0 w. G2 b: P
var now = new Date();
* ^5 |( @9 S" A5 k+ O; ddocument.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>");
: D1 K8 Z' @( L% B- m1 e# z, Tdocument.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>");. |/ }- d$ m6 @1 U4 s, T* q
document.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>");
/ p. _+ A/ L) G, Z l3 q6 E6 |1 cdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>");
0 n& Z0 X+ ~. T) Tdocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>");1 L4 v1 H& t9 J# {5 z
document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>");( l! } ~0 |/ j+ o" F
document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>");
# @! q; U) s2 e u& _8 \7 odocument.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>");% _+ t( d* X- m5 `' s9 i7 |
document.writeln("</TR><TR>");
+ F) U# N$ A9 a4 n1 {# k% b% u: [1 [column = 0;4 \6 \( [1 u% c; Z& X( g8 ]# {3 F
for (i=0; i<startDay; i++) {
% ?% ^0 u3 s/ f# n' D, ndocument.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>");
% G# b: W2 q$ v4 P9 [" gcolumn++;+ ~" m0 i/ e+ V! |! e1 F
}7 f- K" ?# n1 h
, L, r# P) E" k5 ?" sfor (i=1; i<=nDays; i++) {6 A D2 [$ l# g' ~0 I. W' B
if (i == thisDay) {
2 ]/ y5 `! u8 F2 u; T _document.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>")
# F I4 V: P+ L+ Z" m) I}
q& K6 N& B& Telse {
* s7 _9 u6 v8 U( V5 ~$ Z8 Zdocument.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>");
9 b8 e$ w0 `- S4 Q}# C5 c( h9 [3 e
document.writeln(i);3 S, r7 Q- D! }5 h! k8 B3 {
if (i == thisDay) document.writeln("</FONT></TD>")
8 F# F7 _' x; q& S4 D2 P. Ycolumn++;, y H6 g0 j1 ]8 @/ T
if (column == 7) {
1 M. Y4 z7 I" Ydocument.writeln("<TR>"); ) u% `+ e8 y x! [ ]! G2 s; o
column = 0;
1 ~' p _( U& F! X* o! a# B4 o}: |& I/ F8 D9 H. i
}
& r2 R5 l$ j: s8 o0 @document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>")
4 u* `& n5 m% [( c E7 ~( Ndocument.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>")& P+ x9 v9 W& @
document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>")
; s/ _" o7 p1 g9 E: ?' Fdocument.writeln("</TD></TR></TABLE></div>");
& Z& R1 I( e+ y2 p! Z+ |}' D, v, _' p( x- d3 L: I) b4 t0 R
</SCRIPT>6 W! a1 A6 ^, R1 s3 V2 V7 ~
<SCRIPT LANGUAGE="JavaScript">) q$ w) a! \ E6 z) }9 C d5 J$ ^
var timerID = null; G1 q5 {, {% I% C
var timerRunning = false;: w) H) b. ^: X) G
, C2 ~# y/ O& |& }8 `+ Ufunction stopclock (){3 m$ t1 w. e7 b0 c, z9 n
if(timerRunning)
6 C! X- r! C- eclearTimeout(timerID);# E. h) A: H6 t
timerRunning = false;}( u1 }5 `% X" W9 x8 c4 m3 I/ w
! F. A! r; K, F- q6 `. H1 l
//显示当前时间/ h: B% e6 t& K2 U) Y
function showtime () {5 d+ X- ` _: J
var now = new Date();, Z/ T. n3 R" O h* F- o! [ w: {
var hours = now.getHours();- S7 f6 |+ u. {
var minutes = now.getMinutes();6 n. T# h' X1 a
var seconds = now.getSeconds()
2 e. X- T( [" [5 ]var timeValue = " " + ((hours >12) ? hours -12 :hours)
3 b0 h, d0 ^6 j" o F2 \# Z( e6 CtimeValue += ((minutes < 10) ? ":0" : ":") + minutes
- S. Y! Y3 q6 n; PtimeValue += ((seconds < 10) ? ":0" : ":") + seconds
/ X3 h- ~; C- m3 e; ^& l8 j8 ?timeValue += (hours >= 12) ? " 下午 " : " 上午 "
' U4 {. x. A5 t1 hdocument.clock.face.value = timeValue;1 v% c3 `7 C4 Z( C
timerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示
6 k; [! ?2 e+ S& f# A3 z" WtimerRunning = true;}* ~, i' q0 R0 z" U9 A7 v5 d. _
! v4 g& D+ ]3 c: T0 ifunction startclock () {5 ^% L5 I4 S' n- d
stopclock();
$ s$ |0 r5 t# ]showtime();}: i& }$ Z a9 H, R1 c
</SCRIPT>- ?. Y% |8 z7 a& W V' X
4 p! `8 D7 }+ K) e</head>
$ O3 L9 u- E; C" o: w3 N8 `7 j, `4 X: {: _) e
<body bgcolor="#FFFFFF" onLoad="startclock(); timerONE=window.setTimeout"text="#000000">
; g: }6 q. e$ O<script language="JavaScript" type="text/javascript">% r) [5 f+ M3 T4 v5 y
<!--
) q# f. l$ W; r9 F; jcalendar();
$ f: Y& L4 P0 w1 E2 c* J( |//-->
* ~8 l+ t3 {2 j$ u
5 F! ?: Q% s8 ] N/ H( I</script>
% _- p; ]$ f$ P; {, ~/ c& Z
( l" @+ O7 s( ?% S3 y</body>* g" {2 D! w, y. W
</html> |
|