// <div>
// <input type="text" name="time1" id="time1" onclick="MyCalendar.SetDate(this)" value="2006-8-1" />
// <input type="text" name="time2" id="time2" value="2006-8-1" /><input name="" type="button"
// onclick="MyCalendar.SetDate(this,document.getElementById('time2'))" value="选择" />
// </div>
function L_calendar(){}
L_calendar.prototype={
_VersionInfo:"Version:1.0 作者: lingye",
Moveable:true,
NewName:"",
insertId:"",
ClickObject:null,
InputObject:null,
InputDate:null,
IsOpen:false,
MouseX:0,
MouseY:0,
GetDateLayer:function(){
return window.L_DateLayer;
},
L_TheYear:new Date().getFullYear(), //定义年的变量的初始值
L_TheMonth:new Date().getMonth()+1,//定义月的变量的初始值
L_WDay:new Array(39),//定义写日期的数组
MonHead:new Array(31,28,31,30,31,30,31,31,30,31,30,31), //定义阳历中每个月的最大天数
GetY:function(){
var obj;
if (arguments.length > 0){
obj==arguments[0];
}
else{
obj=this.ClickObject;
}
if(obj!=null){
var y = obj.offsetTop;
while (obj = obj.offsetParent) y += obj.offsetTop;
return y;}
else{return 0;}
},
GetX:function(){
var obj;
if (arguments.length > 0){
obj==arguments[0];
}
else{
obj=this.ClickObject;
}
if(obj!=null){
var y = obj.offsetLeft;
while (obj = obj.offsetParent) y += obj.offsetLeft;
return y;}
else{return 0;}
},
CreateHTML:function(){
var htmlstr="";
htmlstr+="<div id=\"L_calendar\">\r\n";
htmlstr+="<span id=\"SelectYearLayer\" style=\"z-index: 9999;position: absolute;top: 3; left: 19;display: none\"></span>\r\n";
htmlstr+="<span id=\"SelectMonthLayer\" style=\"z-index: 9999;position: absolute;top: 3; left: 78;display: none\"></span>\r\n";
htmlstr+="<div id=\"L_calendar-year-month\"><div id=\"L_calendar-PrevM\" onclick=\"parent."+this.NewName+".PrevM()\" title=\"前一月\"><b><</b></div><div id=\"L_calendar-year\" onmouseover=\"style.backgroundColor='#FFD700'\" onmouseout=\"style.backgroundColor='white'\" onclick=\"parent."+this.NewName+".SelectYearInnerHTML('"+this.L_TheYear+"')\"></div><div id=\"L_calendar-month\" onmouseover=\"style.backgroundColor='#FFD700'\" onmouseout=\"style.backgroundColor='white'\" onclick=\"parent."+this.NewName+".SelectMonthInnerHTML('"+this.L_TheMonth+"')\"></div><div id=\"L_calendar-NextM\" onclick=\"parent."+this.NewName+".NextM()\" title=\"后一月\"><b>></b></div></div>\r\n";
htmlstr+="<div id=\"L_calendar-week\"><ul onmouseup=\"StopMove()\"><li>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li></ul></div>\r\n";
htmlstr+="<div id=\"L_calendar-day\">\r\n";
htmlstr+="<ul>\r\n";
for(var i=0;i<this.L_WDay.length;i++){
htmlstr+="<li id=\"L_calendar-day_"+i+"\" style=\"background:#e0e0e0\" onmouseover=\"this.style.background='#FFD700'\" onmouseout=\"this.style.background='#e0e0e0'\"></li>\r\n";
}
htmlstr+="</ul>\r\n";
htmlstr+="<span id=\"L_calendar-today\" onclick=\"parent."+this.NewName+".Today()\"><b>Today</b></span>\r\n";
htmlstr+="</div>\r\n";
//htmlstr+="<div id=\"L_calendar-control\"></div>\r\n";
htmlstr+="</div>\r\n";
htmlstr+="<scr" + "ipt type=\"text/javas" + "cript\">\r\n";
htmlstr+="var MouseX,MouseY;";
htmlstr+="var Moveable="+this.Moveable+";\r\n";
htmlstr+="var MoveaStart=false;\r\n";
htmlstr+="document.onmousemove=function(e)\r\n";
htmlstr+="{\r\n";
htmlstr+="var DateLayer=parent.document.getElementById(\"L_DateLayer\");\r\n";
htmlstr+=" e = window.event || e;\r\n";
htmlstr+="var DateLayerLeft=DateLayer.style.posLeft || parseInt(DateLayer.style.left.replace(\"px\",\"\"));\r\n";
htmlstr+="var DateLayerTop=DateLayer.style.posTop || parseInt(DateLayer.style.top.replace(\"px\",\"\"));\r\n";
htmlstr+="if(MoveaStart){DateLayer.style.left=(DateLayerLeft+e.clientX-MouseX)+\"px\";DateLayer.style.top=(DateLayerTop+e.clientY-MouseY)+\"px\"}\r\n";
htmlstr+=";\r\n";
htmlstr+="}\r\n";
htmlstr+="document.getElementById(\"L_calendar-week\").onmousedown=function(e){\r\n";
htmlstr+="if(Moveable){MoveaStart=true;}\r\n";
htmlstr+=" e = window.event || e;\r\n";
htmlstr+=" MouseX = e.clientX;\r\n";
htmlstr+=" MouseY = e.clientY;\r\n";
htmlstr+=" }\r\n";
htmlstr+="function StopMove(){\r\n";
htmlstr+="MoveaStart=false;\r\n";
htmlstr+=" }\r\n";
htmlstr+="</scr"+"ipt>\r\n";
var stylestr="";
stylestr+="<style type=\"text/css\">";
stylestr+="body{background:#fff;font-size:12px;margin:0px;padding:0px;text-align:left}\r\n";
stylestr+="#L_calendar{border:1px solid blue;width:158px;padding:1px;height:180px;z-index:9998;text-align:center}\r\n";
stylestr+="#L_calendar-year-month{height:23px;line-height:23px;z-index:9998;}\r\n";
stylestr+="#L_calendar-year{line-height:23px;width:60px;float:left;z-index:9998;position: absolute;top: 3; left: 19;cursor:default}\r\n";
stylestr+="#L_calendar-month{line-height:23px;width:48px;float:left;z-index:9998;position: absolute;top: 3; left: 78;cursor:default}\r\n";
stylestr+="#L_calendar-PrevM{position: absolute;top: 3; left: 5;cursor:pointer}"
stylestr+="#L_calendar-NextM{position: absolute;top: 3; left: 145;cursor:pointer}"
stylestr+="#L_calendar-week{height:23px;line-height:23px;z-index:9998;}\r\n";
stylestr+="#L_calendar-day{height:136px;z-index:9998;}\r\n";
stylestr+="#L_calendar-week ul{cursor:move;list-style:none;margin:0px;padding:0px;}\r\n";
stylestr+="#L_calendar-week li{width:20px;height:20px;float:left;;margin:1px;padding:0px;text-align:center;}\r\n";
stylestr+="#L_calendar-day ul{list-style:none;margin:0px;padding:0px;}\r\n";
stylestr+="#L_calendar-day li{cursor:pointer;width:20px;height:20px;float:left;;margin:1px;padding:0px;}\r\n";
stylestr+="#L_calendar-control{height:25px;z-index:9998;}\r\n";
stylestr+="#L_calendar-today{cursor:pointer;float:left;width:63px;height:20px;line-height:20px;margin:1px;text-align:center;background:red}"
stylestr+="</style>";
var TempLateContent="<html>\r\n";
TempLateContent+="<head>\r\n";
TempLateContent+="<title></title>\r\n";
TempLateContent+=stylestr;
TempLateContent+="</head>\r\n";
TempLateContent+="<body>\r\n";
TempLateContent+=htmlstr;
TempLateContent+="</body>\r\n";
TempLateContent+="</html>\r\n";
this.GetDateLayer().document.writeln(TempLateContent);
this.GetDateLayer().document.close();
},
InsertHTML:function(id,htmlstr){
var L_DateLayer=this.GetDateLayer();
if(L_DateLayer){L_DateLayer.document.getElementById(id).innerHTML=htmlstr;}
},
WriteHead:function (yy,mm) //往 head 中写入当前的年与月
{
this.InsertHTML("L_calendar-year",yy + " 年");
this.InsertHTML("L_calendar-month",mm + " 月");
},
IsPinYear:function(year) //判断是否闰平年
{
if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
},
GetMonthCount:function(year,month) //闰年二月为29天
{
var c=this.MonHead[month-1];if((month==2)&&this.IsPinYear(year)) c++;return c;
},
GetDOW:function(day,month,year) //求某天的星期几
{
var dt=new Date(year,month-1,day).getDay()/7; return dt;
},
GetText:function(obj){
if(obj.innerText){return obj.innerText}
else{return obj.textContent}
},
PrevM:function() //往前翻月份
{
if(this.L_TheMonth>1){this.L_TheMonth--}else{this.L_TheYear--;this.L_TheMonth=12;}
this.SetDay(this.L_TheYear,this.L_TheMonth);
},
NextM:function() //往后翻月份
{
if(this.L_TheMonth==12){this.L_TheYear++;this.L_TheMonth=1}else{this.L_TheMonth++}
this.SetDay(this.L_TheYear,this.L_TheMonth);
},
Today:function() //Today Button
{
var today;
this.L_TheYear = new Date().getFullYear();
this.L_TheMonth = new Date().getMonth()+1;
today=n
八款不同风格的日历控件(JS+CSS)4
需积分: 0 80 浏览量
2008-11-17
21:09:54
上传
评论
收藏 5KB RAR 举报
陌上雅南
- 粉丝: 6
- 资源: 15
最新资源
- 珍藏多年的基于matlab实现潮流计算程序源代码集合,包含多个潮流计算程序.rar
- 使用FPGA实现串-并型乘法器
- 基于matlab实现针对基于双曲线定位的DV-Hop算法中误差误差出一种基于加权双曲线定位的DV-Hop改进算法.rar
- 基于matlab实现由遗传算法开发的整数规划,车辆调度问题.rar
- 电视家7.0(对电视配置要求高).apk
- 免费计算机毕业设计-基于JavaEE的医院病历管理系统设计与实现(包含论文+源码)
- 手机端 我的世界融合植物大战僵尸版.apk
- 植物大战僵尸 · 戴夫的老年生活 手机版.apk
- Runcraft · 我的世界跑酷游戏 手机端.apk
- pta题库答案c语言.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0