JS创建日历控件
来源:互联网 发布:ios6好用软件 编辑:程序博客网 时间:2024/04/28 20:45
// JavaScript Document/********************************************************************主题:基于CSS&LI的日历显示作者:Smart/Issac说明:1.调用GetCalendar(InputBoxId);2.问题:IE5下隐含框架zIndex属性不支持;Mozilla下尚不支持若干方法.********************************************************************//*创建框架*/document.writeln("
");document.writeln("");var cDiv = document.getElementById("calendar");var cFrame = document.getElementById("calendarBox");/*基本参数*/var meWidth = cDiv.clientWidth; //日历宽度var meHeight= cDiv.clientHeight; //日历高度var isHidden=true; //日历是否关闭/*取得今日日期*/function GetTodayDate() {today=new Date();yy=today.getYear();mm=(today.getMonth() + 1);if (mm<10) mm='0'+mm;dd=today.getDate();if (dd<10) dd='0'+dd;return yy+'-'+mm+'-'+dd}/*输入今天日期*/function SetTodayDate(InputBoxId) {HiddenCalendar();document.getElementById(InputBoxId).value=GetTodayDate();}/*取某年某月第一天的星期值(月份-1)*/function GetFirstWeek(theYear,theMonth) {return (new Date(theYear,theMonth-1,1)).getDay();}/*取某年某月中总天数*/function GetThisDays(theYear,theMonth) {return (new Date(theYear,theMonth,0)).getDate();}/*取某年某月上个月中总天数*/function GetLastDays(theYear,theMonth) {return (new Date(theYear,theMonth-1,0)).getDate();}/*判断是否是闰年*/function LeapYear(theYear) {if ((theYear%400==0) || ((theYear%4==0) && (theYear%100!=0))) return true;else return false;}/*判断日期(YYYY-MM-DD)的日期是否正确*/function DateIsTrue(asDate) {var lsDate=asDate + "";var loDate=lsDate.split("-");if (loDate.length!=3) return false;var liYear=parseFloat(loDate[0]);var liMonth=parseFloat(loDate[1]);var liDay=parseFloat(loDate[2]);if ((loDate[0].length>4)||(loDate[1].length>2)||(loDate[2].length>2)) return false;if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay)) return false;if ((liYear<1800)||(liYear>2500)) return false;if ((liMonth>12)||(liMonth<=0)) return false;if (GetThisDays(liYear,liMonth)<10) Month='0'+Month;if (Day<10) Day='0'+Day;document.getElementById(InputBoxId).value=Year+"-"+Month+"-"+Day;}/*上一月*/function PrevMonth(InputBoxId,Year,Month,Day) {Month=Month-1;if (Month<1) { Month=12; Year=Year-1; if (Year<1800) Year=2500;}Day=((GetThisDays(Year,Month)12) { Month=1; Year=Year+1; if (Year>2500) Year=1800;}Day=((GetThisDays(Year,Month)<1800) Year=2500;Day=((GetThisDays(Year,Month)2500) Year=1800;Day=((GetThisDays(Year,Month)winWidth)&&(meWidthwinHeight)&&(meHeight";FrameContent+="
«"+nowYear+"年»
";FrameContent+="«"+monthText[nowMonth-1]+"»
";FrameContent+="";FrameContent+="- ";for (i=0; i<7; i++) FrameContent+="
- "+weekText[i]+" ";FrameContent+="
- ";if (fw!=0){ //第一行上月日期 for (i=(ld-fw+1);i<=ld;i++) { if ((w%7)==0) FrameContent+="
- "+i+" "; else FrameContent+="
- "+i+" "; w++; }}for (i=1; i<=td; i++) { if ((w%7)==0) FrameContent+="
- "+i+" "; else if ((w%7)==6) FrameContent+="
- "+i+" "; else FrameContent+="
- "+i+" "; w++;}if (nfw!=0) for (i=1; i<=(7-nfw); i++) FrameContent+="
- "+i+" ";FrameContent+="
- JS创建日历控件
- js日历控件整理
- Js版日历控件
- js:日历控件
- js 日历控件
- JS日历控件事例
- JS日历控件
- JS日历控件
- js日历控件
- js - 日历控件(1)
- js实现日历控件
- js日历控件
- JS日历控件源代码
- js日历控件
- JS日历控件
- js 日历控件
- Js博客日历控件
- JS日历控件
- Android系统原理与源码分析(1):利用Java反射技术阻止通过按钮关闭对话框
- PHPer必备的PHP日期循环知识
- [20110310]工作随笔
- 方正平台帮助企业实现信息化管理
- C#使用Quartz.NET详解
- JS创建日历控件
- SQL Server 2008中的代码安全(四):主密钥
- 数据访问
- kSOAP的运用
- 我遇到了UltraWebGrid控件调试错误的解决办法
- 文件颜色含义
- IBM Websphere培训1——Websphere模块介绍
- javascript 常用代码大全(超级收藏,强烈推荐)
- Fedora 14 开发环境 (update)