HTML元件(HTMLCOMPONENTS)之四編寫日曆(3)(轉)

post0發表於2007-08-15
HTML元件(HTMLCOMPONENTS)之四編寫日曆(3)(轉)[@more@]

===編寫日曆一===

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

}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-957378/,如需轉載,請註明出處,否則將追究法律責任。

相關文章