首页 > 站长学院 > HTML&CSS > HTML组件之:编写日历(3)
 

HTML组件之:编写日历(3)

日期:2005-05-20 00:00:00  来源:中国站长学院
请您记住思索网的网址: http://www.4so.net  [加入收藏夹]

    ===编写日历一===

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);
}


 
 
热门信息
 
相关文章