豆腐制作 都是精品http://www.asp888.net 豆腐技术站 我们经常需要的一些Web项目中用到日历,这样的脚本写起来又麻烦,功能又不够强大,现在豆腐给大家提供一个功能强大的日历程序,这段脚本使用完全的客户端的js脚本制作,运行速度快。下面大家就来看看,还有什么需要改进的地方,先看看效果再说吧!日历演示 豆腐日历 <br />.normal{BACKGROUND: #ffffff}<br />.today {font-weight:bold;BACKGROUND: #6699cc}<br />.satday{color:green}<br />.sunday{color:red}<br />.days {font-weight:bold}<br /> <br />//中文月份,如果想显示英文月份,修改下面的注释<br />/*var months = new Array("January?, "February?, "March",<br />"April", "May", "June", "July", "August", "September",<br />"October", "November", "December");*/<br />var months = new Array("一月", "二月", "三月",<br />"四月", "五月", "六月", "七月", "八月", "九月",<br />"十月", "十一月", "十二月");<br />var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,<br />30, 31, 30, 31);<br />//中文周 如果想显示 英文的,修改下面的注释<br />/*var days = new Array("Sunday", "Monday", "Tuesday",<br />"Wednesday", "Thursday", "Friday", "Saturday");*/<br />var days = new Array("日","一", "二", "三",<br />"四", "五", "六");<br />function getDays(month, year) {<br />//下面的这段代码是判断当前是否是闰年的<br />if (1 == month)<br />return ((0 == year % 4) && (0 != (year % 100))) ||<br />(0 == year % 400) ? 29 : 28;<br />else<br />return daysInMonth[month];<br />} <p>function getToday() {<br />//得到今天的年,月,日<br />this.now = new Date();<br />this.year = this.now.getFullYear();<br />this.month = this.now.getMonth();<br />this.day = this.now.getDate();<br />} <p><br />today = new getToday(); <p>function newCalendar() { <p>today = new getToday();<br />var parseYear = parseInt(document.all.year<br />[document.all.year.selectedIndex].text);<br />var newCal = new Date(parseYear,<br />document.all.month.selectedIndex, 1);<br />var day = -1;<br />var startDay = newCal.getDay();<br />var daily = 0;<br />if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))<br />day = today.day;<br />var tableCal = document.all.calendar.tBodies.dayList;<br />var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());<br />for (var intWeek = 0; intWeek < tableCal.rows.length;intWeek++)<br />for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++)<br />{<br />var cell = tableCal.rows[intWeek].cells[intDay];<br />if ((intDay == startDay) && (0 == daily))<br />daily = 1;<br />if(day==daily)<br />//今天,调用今天的Class<br />cell.className = "today";<br />else if(intDay==6)<br />//周六<br />cell.className = "sunday";<br />else if (intDay==0)<br />//周日<br />cell.className ="satday";<br />else<br />//平常<br />cell.className="normal"; <p>if ((daily > 0) && (daily <= intDaysInMonth))<br />{ <br />cell.innerText = daily;<br />daily++;<br />}<br />else<br />cell.innerText = "";<br />}<br />} <p>function getDate() {<br />var sDate;<br />//这段代码处理鼠标点击的情况<br />if ("TD" == event.srcElement.tagName)<br />if ("" != event.srcElement.innerText)<br />{<br />sDate = document.all.year.value + "年" + document.all.month.value + "月" + event.srcElement.innerText + "日";<br />alert(sDate);<br />}<br />}<br />豆腐制作,都是精品豆腐技术站为大家提供最新最好的技术 <br />for (var intLoop = 0; intLoop < months.length;<br />intLoop++)<br />document.write("<OPTION VALUE= " + (intLoop + 1) + " " +<br />(today.month == intLoop ?<br />"Selected" : "") + ">" +<br />months[intLoop]);<br /> <br />for (var intLoop = today.year-50; intLoop < (today.year + 4);<br />intLoop++)<br />document.write("<OPTION VALUE= " + intLoop + " " +<br />(today.year == intLoop ?<br />"Selected" : "") + ">" +<br />intLoop);<br /> <p>document.write("<TD class=satday>" + days[0] + "");<br />for (var intLoop = 1; intLoop < days.length-1;<br />intLoop++) <br />document.write("<TD>" + days[intLoop] + "");<br />document.write("<TD class=sunday>" + days[intLoop] + "");<br /> <br />for (var intWeeks = 0; intWeeks < 6; intWeeks++) {<br />document.write("<TR style='cursor:hand'>");<br />for (var intDays = 0; intDays < days.length;<br />intDays++)<br />document.write("<TD>");<br />document.write("");<br />}<br /> function Cancel() {document.all.ret.value = "";window.close();}