Maison > Article > développement back-end > 一个非常精彩的日历程序_PHP教程
豆腐制作 都是精品 我们经常需要的一些Web项目中用到日历,这样的脚本写起来又麻烦,功能又不够强大,现在豆腐给大家
http://www.asp888.net 豆腐技术站
提供一个功能强大的日历程序,这段脚本使用完全的客户端的js脚本制作,运行速度快。
下面大家就来看看,还有什么需要改进的地方,先看看效果再说吧!日历演示
function getToday() {
//得到今天的年,月,日
this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
today = new getToday();
function newCalendar() {
today = new getToday();
var parseYear = parseInt(document.all.year
[document.all.year.selectedIndex].text);
var newCal = new Date(parseYear,
document.all.month.selectedIndex, 1);
var day = -1;
var startDay = newCal.getDay();
var daily = 0;
if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
day = today.day;
var tableCal = document.all.calendar.tBodies.dayList;
var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());
for (var intWeek = 0; intWeek for (var intDay = 0;intDay {
var cell = tableCal.rows[intWeek].cells[intDay];
if ((intDay == startDay) && (0 == daily))
daily = 1;
if(day==daily)
//今天,调用今天的Class
cell.className = "today";
else if(intDay==6)
//周六
cell.className = "sunday";
else if (intDay==0)
//周日
cell.className ="satday";
else
//平常
cell.className="normal";
if ((daily > 0) && (daily {
cell.innerText = daily;
daily++;
}
else
cell.innerText = "";
}
}
function getDate() {
var sDate;
//这段代码处理鼠标点击的情况
if ("TD" == event.srcElement.tagName)
if ("" != event.srcElement.innerText)
{
sDate = document.all.year.value + "年" + document.all.month.value + "月" + event.srcElement.innerText + "日";
alert(sDate);
}
}
|
||||||
function Cancel() {
document.all.ret.value = "";
window.close();
}