源码学习:一个简单的日历控件(2)
var tbBoard=document.createElement("table");
8 r% \4 n8 Z* n8 y/ Q& u6 O( f" M3 C divBoard.insertAdjacentElement("beforeEnd",tbBoard);4 R9 t8 x8 E7 }! |: g/ h: m: ?
tbBoard.style.cssText="position:absolute;top:0;left:0;width:100%;height:10;font-size:9pt;";6 h0 J# m3 E; f. h, T
tbBoard.cellPadding=0;
$ u6 }) ~" \4 j6 a tbBoard.cellSpacing=1;
# M$ T/ L/ C: X6 \ tbBoard.bgColor="#333333";
' C% N f3 D. n5 w
( S v& ]$ T/ P2 {, Y; i _- k$ b- k
, w J/ Z, f7 p I! c
8 W) @. f B2 {3 T/ L /************** 设置各功能按钮的功能 *********************/
9 [) J( l' M- Q0 A2 _7 f4 f% I2 ^' G /*********** Calendar About Button ***************/4 o3 H' B5 z" s1 p& j
trRow = tbBoard.insertRow(0);) l( A+ F5 ~, w2 s! I
calendar.calendarAbout=calendar.insertTbCell(trRow,0,"-","center");
7 u/ V: n, k( }0 b, D calendar.calendarAbout.onclick=function(){calendar.about();}6 ?+ F. ^0 s8 {4 g8 z+ `: b
/*********** Calendar Head ***************/
; z( `! H2 c0 T4 `! ?% \/ b tbCell=trRow.insertCell(1);
1 }9 s0 u9 Y3 l! y9 b- \ tbCell.colSpan=5;
2 G7 g/ {. R; U; T9 b0 u" z% g$ j tbCell.bgColor="#99CCFF";2 F" V6 n' U% T. U3 {' h- K
tbCell.align="center";2 @% k. Q% Y% W4 w+ A5 e
tbCell.style.cssText = "cursor:default";
* k% `1 {4 X6 d5 l) G. | calendar.head=tbCell;
( ]( e5 G+ b- i2 e# M /*********** Calendar Close Button ***************/2 f9 H% C" ?8 z; ]2 [5 Q
tbCell=trRow.insertCell(2);
% f0 P; S) t; }" e. Q" q N calendar.calendarClose = calendar.insertTbCell(trRow,2,"x","center");" ?( U1 z" R( k5 ?2 M7 d: ?
calendar.calendarClose.title="关闭";
0 C# M8 ?' i2 y% I7 b; p, R7 f M calendar.calendarClose.onclick=function(){calendar.hide();} # `9 J0 V( X: A3 S
' t, k# N) k( m" e
/*********** Calendar PrevYear Button ***************/
# I8 @7 x- O' U trRow = tbBoard.insertRow(1);. D/ l: f/ V3 P( N
calendar.prevYear = calendar.insertTbCell(trRow,0,"lt;lt;","center");
% }: a# J9 S D1 @ calendar.prevYear.title="上一年";% ~8 e# F6 o1 m7 E9 F0 T2 D
calendar.prevYear.onmousedown=function(){
: k$ B+ d/ ^9 P calendar.currentDate[0]--;. k' ^9 q! q X$ b" n( T) z$ |. C
calendar.show(calendar.target,calendar.currentDate[0] "-" calendar.currentDate[1] "-" calendar.currentDate[2],calendar.source);1 f# v1 v% }" l6 w0 { r
}2 ?$ y$ D: j9 z* L
/*********** Calendar PrevMonth Button ***************/
- u* ]) b# c* ]+ h calendar.prevMonth = calendar.insertTbCell(trRow,1,"lt;","center");
0 e& d. ?6 d( v+ b0 T5 G3 z( T; C calendar.prevMonth.title="上一月";- u2 f( [4 }$ x) ]2 e0 @1 h' F. q: j1 E
calendar.prevMonth.onmousedown=function(){
点击图标进入精品网摘收藏 欢迎大家加入网络收藏夹