All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
javascript实现广告页面的定时关闭_JavaScript技术_编程技术
MySQL,Query,Profile_mssql学习_编程技术
ASP.NET从零起步设计网站全过程(10)_[Asp.Net教程]
Discuz论坛2.5,升级到PHP,MySQL新版遇到的问题_php资料_编程技术
ASP.NET从零起步设计网站全过程(2)_[Asp.Net教程]
PHP配置链接access数据库_[PHP教程]
向普通人加密,用PHP程序保护数据_php资料_编程技术
SQL注入漏洞全接触(高级篇,)_[SQL,Server教程]
Asp.Net,Ajax,学习笔记15,如何使用ASP.NET,Profile_[Asp.Net教程]
ASP.NET如何保留两位小数点_.net资料_编程技术
Reading number is top 10 pictures
So beauty, will let you spray blood5
Fierce chengdu woman, street rape man
美女
初吻给了谁?
关于海盗的研究
男人帮杂志里的惹火性感美女2
支持判处贩卖儿童者死刑
Absolutely shocked. National geographic 50 animal photographys4
A man's favorite things12
Chinese paper-cut grilles art appreciation8
Download software ranking
matrix1
I for your crazy
尖东毒玫瑰A
Proficient in JavaScript
Unix video tutorial8
WebService在.NET中的实战应用教学视频 → 第1集
Unix video tutorial13
Such love down(擒爱记)
超级战舰
实战黑客不求人
归海一刀 published in(发表于) 2014/3/30 5:18:29 Edit(编辑)
HTML组件HTML COMPONENTS之四_[Html教程]

HTML组件HTML COMPONENTS之四_[Html教程]

HTML组件HTML COMPONENTS之四_[Html教程]
===编写日历一===

  当calendar.html调用 MYCAL:CALENDAR,当月的日历将会显示在页面中,函数setCal()是主要程序段,它初始化一些变量并调用drawCal()函数。我们也使用了三个别的函数:getMonthName()、 getDays() 和 leapYear()。让我们从最后一个函数开始:

  getDays()函数接收哪月值和哪年值,并且建立一个有12个元素的数组,用来存放每月的天数,哪一年用来决定是不是闰年,在闰年中二月是29天,而不是闰年是28天。该函数返回指定月份的天数。

以下是getDays():

function getDays(month, year) {
// create array to hold number of days in each month
var ar = new Array(12);
ar[0] = 31; // January
ar[1] = (leapYear(year)) ? 29 : 28; // February
ar[2] = 31; // March
ar[3] = 30; // April
ar[4] = 31; // May
ar[5] = 30; // June
ar[6] = 31; // July
ar[7] = 31; // August
ar[8] = 30; // September
ar[9] = 31; // October
ar[10] = 30; // November
ar[11] = 31; // December

// return number of days in the specified month (parameter)
return ar[month];
}

如果指定的年数可以被4整除,那么leapYear()函数将返回“true”,否则返回”false“:

function leapYear(year) {
if (year % 4 == 0) // basic rule
return true; // is leap year
/* else */ // else not needed when statement is "return"
return false; // is not leap year
}
getMonthName()函数返回指定月份的名字:
function getMonthName(month) {
// create array to hold name of each month
var ar = new Array(12);
ar[0] = "January";
ar[1] = "February";
ar[2] = "March";
ar[3] = "April";
ar[4] = "May";
ar[5] = "June";
ar[6] = "July";
ar[7] = "August";
ar[8] = "September";
ar[9] = "October";
ar[10] = "November";
ar[11] = "December";

// return name of specified month (parameter)
return ar[month];
}

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




 
 
 
 
 


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.