当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > HTML组件之:编写日历(3)

HTML/XHTML教程
表格边框的css语法整理
超文标记语言简明导引
如何将 CSS 加入网页
CSS技术在网页设计中的运用
css 新手上路
网页特效大公开
CSS重新定义项目符号和编号
中文网页制作中段落缩进的方法
制作虚线效果的水平线
初步了解CSS3
CSS滤镜:概述
CSS定位二:空间定位
CSS滤镜:Gray属性
CSS属性(颜色背景属性)
CSS属性(字体属性)
CSS定位一:动态转换
CSS属性(文本属性)
CSS属性("容器"属性)
CSS属性(分级属性)
CSS属性(鼠标属性)

HTML/XHTML教程 中的 HTML组件之:编写日历(3)


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

===编写日历一===

setCal()函数是主模块,我们在脚本的第一行调用它。该函数为当天(now)、和每月的第一天(firstDayInstance)建立一个Date对象。用这些对象,setCal()函数解析出关于一个月的第一天、当日,和最后一天的所有信息。

function setCal() {
// standard time attributes
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth();
var monthName = getMonthName(month);
var date = now.getDate();
now = null;

// create instance of first day of month, and extract the day on which it occurs
var firstDayInstance = new Date(year, month, 1);
var firstDay = firstDayInstance.getDay();
firstDayInstance = null;

// number of days in current month
var days = getDays(month, year);

// call function to draw calendar
drawCal(firstDay + 1, days, date, monthName, year);
}