当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 又一日历输入效果没考虑兼容性,IE通过

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 又一日历输入效果没考虑兼容性,IE通过


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 107 ::
收藏到网摘: n/a

点击运行可以看到效果:
[Ctrl+A 全选 提示:你可先修改部分代码,再按运行]

做得比较急,所以没考虑兼容性。
通过两个类实现,一个是面板类,一个是日历类。
由于我开发时所有公共js都是在顶级窗口一次加载的,所以在子窗口创建对象时需要把当前窗口对象传进去,例如: var panel = new parent.parent.SelectPanel(self);如果没传self参数,默认就是加载js的窗口。
marcian 在网上找的那个公历算法有点复杂,呵呵。我获取当前月最大天数,以及当前月第一天是星期几是直接通过JS自带的Date函数来实现的。
复制代码 代码如下:

// 获取当月最大天数
//asfman提供更简单的方式:return (new Date(y, m+1, 0)).getDate()
function GetDates(year, month)
{
var date = new Date(year, month, 31);
return 31 - date.getDate() || 31;
}
// 获取当月第一天是星期几
function GetFirstDay(year, month)
{
return (new Date(year, month, 1)).getDay();
}

/* 下面这部分可以不要,因为即使出现new Date(2007, -1, 31),这种现象,Date会自动转换成Date(2006, 12, 31)
if(month < 0)
{
month = 11;
year--;
}
if(month == 12)
{
month = 0;
year++;
}*/