欢迎来到天天文库
浏览记录
ID:24374479
大小:52.50 KB
页数:3页
时间:2018-11-14
《html组件html ponents之四--.》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、HTML组件HTMLPONENTS之四>>.===编写日历一=== 当calendar.html调用MYCAL:CALENDAR,当月的日历将会显示在页面中,函数setCal()是主要程序段,它初始化一些变量并调用drae()、getDays()和leapYear()。让我们从最后一个函数开始: getDays()函数接收哪月值和哪年值,并且建立一个有12个元素的数组,用来存放每月的天数,哪一年用来决定是不是闰年,在闰年中二月是29天,而不是闰年是28天。该函数返回指定月份的天数。以下是getDays():functiongetDays(month,year){//cre
2、atearraytoholdnumberofdaysineachmonthvarar=neberar[9]=31;//Octoberar[10]=30;//Novemberar[11]=31;//December//returnnumberofdaysinthespecifiedmonth(parameter)returnar[month];}如果指定的年数可以被4整除,那么leapYear()函数将返回“true”,否则返回”false“:functionleapYear(year){if(year%4==0)//basicrulereturntrue;//isleapye
3、ar/*else*///elsenotneededentis"return"returnfalse;//isnotleapyear}getMonthName()函数返回指定月份的名字:functiongetMonthName(month){//createarraytoholdnameofeachmonthvarar=neber";ar[9]="October";ar[10]="November";ar[11]="December";//returnnameofspecifiedmonth(parameter)returnar[month];}setCal()函数是主模块,我
4、们在脚本的第一行调用它。该函数为当天(noeattributesvarnoonth=noonthName=getMonthName(month);vardate=noonth,andextractthedayononth,1);varfirstDay=firstDayInstance.getDay();firstDayInstance=null;//numberofdaysincurrentmonthvardays=getDays(month,year);//callfunctiontodraonthName,year);}[这篇文章来自..,]
此文档下载收益归作者所有