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

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 112 ::
收藏到网摘: 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++;
}*/