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

HTML/XHTML教程
“mailto”的六则应用技巧
meta标签之详解
按形容词分类:活泼、快乐、有趣
按形容词分类:狂野、充沛、动感
按形容词分类:高尚、自然、安稳
按形容词分类:简单、洁净、进步
按颜色分类:黑色和白色(Black & White)
按颜色分类:橙色系(Yellow Red)
按颜色分类:蓝色系(Blue)
按颜色分类:紫色系(Purple)
按形容词分类:冷静、自然
按形容词分类:传统、稳重、古典
按形容词分类:柔和、洁净、爽朗
按颜色分类:黄绿色系(Yellow Green)
按颜色分类:绿色系(Green)
按颜色分类:青绿色系(Blue Green)
按形容词分类:传统、高雅、优雅
按颜色分类:紫红色系(Red Purple)
按形容词分类:华丽、花哨、女性化
按形容词分类:简单、进步、时尚

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 72 ::
收藏到网摘: 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);
}