一个日历兼容多种浏览器Word文档下载推荐.docx
《一个日历兼容多种浏览器Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《一个日历兼容多种浏览器Word文档下载推荐.docx(17页珍藏版)》请在冰豆网上搜索。
*参数2:
按钮或其它可用单击事件的HTML元素(如果使用按钮方式则必填).
如onclick="
c.show(this,document.all.*)"
*=文本输入框名称
*参数3:
如果没有文本框没有值则使用该值初始化日历(选填).
如onfocus="
c.show(this,'
2006-01-01'
)
*注:
参数顺序不分先后.MSIE6/Opera8/FireFox1.5下测试通过
************************如果您使用本日历控件请保留该信息谢谢!
***************************
*
*Email:
caoailin@
*QQ:
38062022
*Creationdate:
2006-10-29
*********************************************************************************************/
functionCalendar(objName)
{
this.style={
borderColor:
#909eff"
//边框颜色
headerBackColor:
#909EFF"
//表头背景颜色
headerFontColor:
#ffffff"
//表头字体颜色
bodyBarBackColor:
#f4f4f4"
//日历标题背景色
bodyBarFontColor:
#000000"
//日历标题字体色
bodyBackColor:
//日历背景色
bodyFontColor:
//日历字体色
bodyHolidayFontColor:
#ff0000"
//假日字体色
watermarkColor:
#d4d4d4"
//背景水印色
};
this.Obj=objName;
this.date=null;
this.mouseOffset=null;
this.dateInput=null;
this.timer=null;
this.drag=false;
};
Calendar.prototype.toString=function()
varstr=this.getStyle();
str+='
divclass="
calendar"
style="
display:
none;
"
onselectstart="
returnfalse"
oncontextmenu="
id="
Calendar"
\n'
cdrWatermark"
/div>
divstyle="
position:
absolute;
left:
0px;
top:
z-index:
2;
width:
140px;
'
str+=this.getHeader();
str+=this.getBody();
divid="
cdrMenu"
3;
onmouseover="
+this.Obj+'
.showMenu(null);
onmouseout="
.hideMenu();
returnstr;
Calendar.prototype.getStyle=function()
varstr='
styletype="
text/css"
.calendar{position:
142px;
height:
174px;
background-color:
+this.style.bodyBackColor+'
border:
1pxsolid'
+this.style.borderColor+'
9999;
}\n'
.cdrHeader{background-color:
+this.style.headerBackColor+'
22px;
font-size:
12px;
color:
+this.style.headerFontColor+'
.cdrWatermark{position:
55px;
font-family:
ArialBlack;
50px;
+this.style.watermarkColor+'
1;
text-align:
center;
.cdrBodyBar{background-color:
+this.style.bodyBarBackColor+'
+this.style.bodyBarFontColor+'
20px;
.cdrBody{width:
cursor:
pointer;
+this.style.bodyFontColor+'
.dayOver{border:
1pxsolidblack;
#f4f4f4;
.menuOver{background-color:
+this.style.headerBackColor+'
.headerOver{border:
black;
default;
.cdrMenu{font-size:
1pxsolid#000000;
#ffffff;
100%}\n'
/style>
Calendar.prototype.getHeader=function()
tableclass="
cdrHeader"
cellSpacing="
2"
cellPadding="
0"
tralign="
center"
tdonmouseover="
this.className=\'
headerOver\'
\'
previousYear"
title="
上一年份"
10px;
onclick="
+this.Obj+'
.onChangeYear(false);
/td>
previousMonth"
上一月份"
.onChangeMonth(false);
currentYear"
.showMenu(true);
0<
currentMonth"
.showMenu(false);
nextMonth"
下一月份"
.onChangeMonth(true);
nextYear"
下一年份"
.onChangeYear(true);
/tr>
/table>
Calendar.prototype.getBody=function()
varn=0;
tableid="
cdrBodyBar"
class="
onmousedown="
.onDragStart()"
onmousemove="
.onMouseMove()"
move;
middle"
td>
日<
一<
二<
三<
/TD>
四<
五<
六<
cdrBody"
for(i=0;
i<
6;
i++)
{
for(j=0;
j<
7;
j++)
tdid="
cdrDay'
+(n++)+'
width="
13%"
height="
16"
}
tdstyle="
.getToday();
今天<
Calendar.prototype.getYearMenu=function(year)
tablecellSpacing="
10;
var_year=year+i;
var_date=newDate(_year,this.date.getMonth(),this.date.getDate());
tdwidth="
'
if(this.date.getFullYear()!
=_year)
onmouseover="
menuOver\'
else
class="
menuOver"
onclick="
.bindDate(\'
+_date.toFormatString("
-"
)+'
)"
+_year+'
年<
tablestyle="
100%;
.getYearMenu('
+(year-10)+'
+(year+10)+'
tr>
var_menu=this.getObjById("
_menu.innerHTML=str;
Calendar.prototype.getMonthMenu=function()
for(i=1;
=12;
var_date=newDate(this.date.getFullYear(),i-1,this.date.getDate());
tdheight="
if(this.date.getMonth()+1!
=i)
+i+'
月<
Calendar.prototype.show=function(arg1,arg2,arg3)
if(arguments.length>
3||arguments.length==0)
alert("
对不起!
传入参数不对!
);
return;
var_date=null;
var_evObj=null;
var_initValue=null
arguments.length;
if(typeof(arguments[i])=="
object"
&
&
arguments[i].type=="
text"
{_date=arguments[i];
}
elseif(typeof(arguments[i])=="
{_evObj=arguments[i];
string"
{_initValue=arguments[i];
_evObj=_evObj||_date;
if(!
_date){alert("
传入参数错误!
this.dateInput=_date;
_date=_date.value;
if(_date=="
_initValue)_date=_initValue;
this.bindDate(_date);
var_target=this.getPosition(_evObj);
var_obj=this.getObjById("
_obj.style.display="
_obj.style.left=_target.x;
if((document.body.clientHeight-(_target.y+_evObj.clientHeight))>
=_obj.clientHeight)
_obj.style.top=_target.y+_evObj.clientHeight;
_obj.style.top=_target.y-_obj.clientHeight;
Calendar.prototype.hide=function()
varobj=this.getObjById("
obj.style.display="
none"
Calendar.prototype.bindDate=function(date)
var_monthDays=newArray(31,30,31,30,31,30,31,31,30,31,30,31);
var_day=1;
var_arr=date.split('
-'
var_date=newDate(_arr[0],_arr[1]-1,_arr[2]);
if(isNaN(_date))_date=newDate();
this.date=_date;
this.bindHeader();
var_year=_date.getFullYear();
var_month=_date.getMonth();
_monthDays[1]=((_year%4==0)&
(_year%100!
=0)||(_year%400==0))?
29:
28;
42;
var_dayElement=this.getObjById("
cdrDay"
+i);
_dayElement.onmouseover=Function(this.Obj+"
.onMouseOver(this)"
_dayElement.onmouseout=Function(this.Obj+"
.onMouseOut(this)"
_dayElement.onclick=Function(this.Obj+"
.onClick(this)"
this.onMouseOut(_dayElement);
if(i>
=new