日期插件.docx
- 文档编号:29172973
- 上传时间:2023-07-21
- 格式:DOCX
- 页数:17
- 大小:20.14KB
日期插件.docx
《日期插件.docx》由会员分享,可在线阅读,更多相关《日期插件.docx(17页珍藏版)》请在冰豆网上搜索。
日期插件
--
/*调用方法:
100%;"/> */ varcal_Width=180;//定义日历显示的宽度,至少140 document.write(" absolute;z-index: 9999;width: "+(cal_Width+4).toString()+"px;height: 193px;display: none'>"); document.write("
varWebCalendar=newWebCalendar();
functiondocument.onclick()
{
if(WebCalendar.eventSrc!
=window.event.srcElement)hiddenCalendar();
}
functionWebCalendar()//初始化日历的设置
{
this.regInfo="WEBCalendarver3.0 关闭的快捷键:
[Esc]";
this.dayShow=38;//定义页面上要显示的天数,不能小于35,或大于39
this.daysMonth=newArray(31,28,31,30,31,30,31,31,30,31,30,31);
this.day=newArray(this.dayShow);//定义日历展示用的数组
this.dayObj=newArray(this.dayShow);//定义日期展示控件数组
this.dateStyle=null;//保存格式化后日期数组
this.objExport=null;//日历回传的显示控件
this.eventSrc=null;//日历显示的触发控件
this.inputDate=null;//转化外的输入的日期(d/m/yyyy)
this.thisYear=newDate().getFullYear();//定义年的变量的初始值
this.thisMonth=newDate().getMonth()+1;//定义月的变量的初始值
this.thisDay=newDate().getDate();//定义日的变量的初始值
this.today=this.thisDay+"/"+this.thisMonth+"/"+this.thisYear;//今天(d/m/yyyy)
this.iframe=window.frames("meizzCalendarIframe");//日历的iframe载体
this.calendar=getObjectById("meizzCalendarLayer");//日历的层
this.dateReg="";//日历格式验证的正则式
this.yearFall=50;//定义显示的年份下拉框的年差值,如果今年是2000年,这里设置为50,就显示1950-2050
this.format="yyyy-mm-dd";//回传日期的格式
this.timeShow=false;//是否返回时间
this.drag=true;//是否允许拖动
this.darkColor="#95B7F3";//控件的暗色
this.lightColor="#FFFFFF";//控件的亮色
this.btnBgColor="#E6E6FA";//控件的按钮背景色
this.wordColor="#000080";//控件的文字颜色
this.wordDark="#DCDCDC";//控件的暗文字颜色
this.dayBgColor="#F5F5FA";//日期数字背景色
this.todayColor="#FF0000";//今天在日历上的标示背景色
this.DarkBorder="#D4D0C8";//日期显示的立体表达色
this.yearOption="";
varyearNow=newDate().getFullYear();
yearNow=(yearNow<=1000)?
1000:
((yearNow>=9999)?
9999:
yearNow);
varyearMin=(yearNow-this.yearFall>=1000)?
yearNow-this.yearFall:
1000;
varyearMax=(yearNow+this.yearFall<=9999)?
yearNow+this.yearFall:
9999;
yearMin=(yearMax==9999)?
yearMax-this.yearFall*2:
yearMin;
yearMax=(yearMin==1000)?
yearMin+this.yearFall*2:
yearMax;
for(vari=yearMin;i<=yearMax;i++)this.yearOption+="
}
functionwriteIframe()
{
varstrIframe="
0px'oncontextmenu='returnfalse'>
if(WebCalendar.drag){strIframe+="
"vardrag=false,cx=0,cy=0,o=parent.WebCalendar.calendar;functiondocument.onmousemove(){"+
"if(parent.WebCalendar.drag&&drag){if(o.style.left=='')o.style.left=0;if(o.style.top=='')o.style.top=0;"+
"o.style.left=parseInt(o.style.left)+window.event.clientX-cx;"+
"o.style.top=parseInt(o.style.top)+window.event.clientY-cy;}}"+
"functiondocument.onkeydown(){switch(window.event.keyCode){case27:
parent.hiddenCalendar();break;"+
"case37:
parent.prevM();break;case38:
parent.prevY();break;case39:
parent.nextM();break;case40:
parent.nextY();break;"+
"case84:
document.forms[0].today.click();break;}"+
"try{window.event.keyCode=0;window.event.returnValue=false;}catch(ee){}}"+
"functiondragStart(){cx=window.event.clientX;cy=window.event.clientY;drag=true;}"}
strIframe+="
"
"
" ←'style='cursor: hand'onclick='parent.prevM()'><"+ " "onmouseover='this.bgColor=parent.WebCalendar.darkColor;this.style.color=parent.WebCalendar.lightColor'"+ "onmouseout='this.bgColor=parent.WebCalendar.lightColor;this.style.color=parent.WebCalendar.wordColor'>"+ " 100%;'"+ "onchange='parent.WebCalendar.thisYear=this.value;parent.hiddenSelect(this);parent.writeCalendar();'>"; //varyearNow=newDate().getFullYear(); //yearNow=(yearNow<=1000)? 1000: ((yearNow>=9999)? 9999: yearNow); //varyearMin=(yearNow-WebCalendar.yearFall>=1000)? yearNow-WebCalendar.yearFall: 1000; //varyearMax=(yearNow+WebCalendar.yearFall<=9999)? yearNow+WebCalendar.yearFall: 9999; //yearMin=(yearMax==9999)? yearMax-WebCalendar.yearFall*2: yearMin; //yearMax=(yearMin==1000)? yearMin+WebCalendar.yearFall*2: yearMax; //for(vari=yearMin;i<=yearMax;i++)strIframe+=" strIframe+=WebCalendar.yearOption+""+ ""+ " "onmouseover='this.bgColor=parent.WebCalendar.darkColor;this.style.color=parent.WebCalendar.lightColor'"+ "onmouseout='this.bgColor=parent.WebCalendar.lightColor;this.style.color=parent.WebCalendar.wordColor'>"+ " 100%;'"+ "onchange='parent.WebCalendar.thisMonth=this.value;parent.hiddenSelect(this);parent.writeCalendar();'>"; for(vari=1;i<13;i++)strIframe+=" strIframe+=""+ ""+ " →'onclick='parent.nextM()'style='cursor: hand'>>
"
" if(WebCalendar.drag){strIframe+="onmousedown='dragStart()'onmouseup='drag=false'";} strIframe+="borderColorLight='"+WebCalendar.darkColor+"'borderColorDark='"+WebCalendar.lightColor+"'>"+ "一 二 三 四 五 六
"
"
for(varx=0;x<5;x++){
strIframe+="
for(vary=0;y<7;y++)
strIframe+="
strIframe+="
}
strIframe+="
for(varx=35;x strIframe+=" strIframe+=" center;'title='"+WebCalendar.regInfo+"'>"+ " "+WebCalendar.btnBgColor+";cursor: hand;padding-top: 2px;width: 44%;height: 100%;'onfocus='this.blur()'"+ "type=buttonvalue='清空'onclick='parent.WebCalendar.objExport.value=\"\";parent.hiddenCalendar()'>"+ " "+ " "+WebCalendar.btnBgColor+";cursor: hand;padding-top: 2px;width: 43%;height: 100%;'onfocus='this.blur()'"+ "type=buttonvalue='关闭'onclick='parent.hiddenCalendar()'>"+ "
"
"
"
↑'onclick='parent.prevY()'type=buttonvalue='<<'"+
"onfocus='this.blur()'style='meizz:
expression(this.disabled=parent.WebCalendar.thisYear==1000)'>
"onfocus='this.blur()'name=prevMonthtitle='向前翻1月 快捷键:
←'onclick='parent.prevM()'type=buttonvalue='< '>"+
"
50px;'title='当前日期 快捷键:
T'"+
"onclick=\"parent.returnDate(newDate().getDate()+'/'+(newDate().getMonth()+1)+'/'+newDate().getFullYear())\">"+
" →'name=nextMonthonclick='parent.nextM()'type=buttonvalue=' >'"+ "onfocus='this.blur()'> ↓'onclick='parent.nextY()'type=buttonvalue='>>'"+ "onfocus='this.blur()'style='meizz: expression(this.disabled=parent.WebCalendar.thisYear==9999)'>
"