📄 一个非常精彩的日历程序.htm
字号:
<TR>
<TD class=p4 colSpan=2>
<BLOCKQUOTE><BR><BR>我们经常需要的一些Web项目中用到日历,这样的脚本写起来又麻烦,功能又不够强大,现在豆腐给大家
<BR>提供一个功能强大的日历程序,这段脚本使用完全的客户端的js脚本制作,运行速度快。
<BR>下面大家就来看看,还有什么需要改进的地方,先看看效果再说吧!日历演示 <BR><HTML>
<BR><HEAD> <BR><TITLE>豆腐日历</TITLE> <BR><!--
请不要删除这段版权信息 --> <BR><!-- <BR>豆腐制作 都是精品
<BR>http://www.asp888.net 豆腐技术站 <BR>--> <BR><STYLE
TYPE="text/css"> <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></STYLE> <BR><SCRIPT LANGUAGE="JavaScript">
<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></P>
<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>
<P><BR>today = new getToday(); </P>
<P>function newCalendar() { </P>
<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>
<P>if ((daily > 0) && (daily <= intDaysInMonth))
<BR>{ <BR>cell.innerText = daily; <BR>daily++; <BR>} <BR>else
<BR>cell.innerText = ""; <BR>} <BR>} </P>
<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></SCRIPT> <BR></HEAD> <BR><BODY
ONLOAD="newCalendar()" OnUnload="window.returnValue =
document.all.ret.value;"> <BR>豆腐制作,都是精品 <BR><br>
<BR><a href="http://www.asp888.net"
targer=_blank>豆腐技术站</a>为大家提供最新最好的技术 <BR><input
type="hidden" name="ret"> <BR><TABLE ID="calendar"
cellspacing="0" cellpadding="0"> <BR><THEAD>
<BR><TR> <BR><TD COLSPAN=7 ALIGN=CENTER>
<BR><SELECT ID="month" ONCHANGE="newCalendar()">
<BR><SCRIPT LANGUAGE="JavaScript"> <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></SCRIPT> <BR></SELECT> </P>
<P><SELECT ID="year" ONCHANGE="newCalendar()">
<BR><SCRIPT LANGUAGE="JavaScript"> <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></SCRIPT> <BR></SELECT>
<BR></TD> <BR></TR> <BR><TR CLASS="days">
<BR><SCRIPT LANGUAGE="JavaScript"> </P>
<P>document.write("<TD class=satday>" + days[0] +
"</TD>"); <BR>for (var intLoop = 1; intLoop <
days.length-1; <BR>intLoop++) <BR>document.write("<TD>" +
days[intLoop] + "</TD>"); <BR>document.write("<TD
class=sunday>" + days[intLoop] + "</TD>");
<BR></SCRIPT> <BR></TR> <BR></THEAD>
<BR><TBODY border=1 cellspacing="0" cellpadding="0"
ID="dayList"ALIGN=CENTER ONCLICK="getDate()"> <BR><SCRIPT
LANGUAGE="JavaScript"> <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></TD>");
<BR>document.write("</TR>"); <BR>} <BR></SCRIPT>
<BR></TBODY> <BR></TABLE> <BR><center><Input
Style="width:50pt" type=button value="Cancel"
OnClick="Cancel();"></center> <BR></BODY>
<BR></HTML> </P>
<P><Script Language="JavaScript1.2"> </P>
<P>function Cancel() { <BR>document.all.ret.value = "";
<BR>window.close(); <BR>} </P>
<P></script> <BR></P>
<P><BR><BR></P></BLOCKQUOTE></TD></TR>
<TR>
<TD class=p4 vAlign=top width="50%">
<BLOCKQUOTE>原作者:不详<BR>来 源:不详<BR>共有2885位读者阅读过此文<BR>【<A
href="http://bbs.aspsky.net/list.asp?boardid=1">发表评论</A>】
</BLOCKQUOTE></TD>
<TD class=p4 vAlign=top width="50%">
<P>
<LI><FONT color=#0772b1>上篇文章</FONT>:<A
href="http://www.aspsky.net/article/list.asp?id=1504">SQL中代替Like语句的另一种写法</A>
<BR>
<LI><FONT color=#0772b1>下篇文章</FONT>:<A
href="http://www.aspsky.net/article/list.asp?id=1506">在Linux环境下安装jsp</A>
</LI></TD></TR>
<TR>
<TD bgColor=#297dff class=p4 height=20 width="50%"><FONT
color=#ceffff> → 本周热门</FONT></TD>
<TD bgColor=#297dff class=p4 width="50%"><FONT color=#ceffff> →
相关文章</FONT></TD></TR>
<TR>
<TD bgColor=#586011 colSpan=2 height=1><SPACER type="block"
width="1"></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR>
<TR>
<TD class=p4 vAlign=top width="50%">
<LI><A href="http://www.aspsky.net/article/list.asp?id=1510"
target=_top title="SQL Server 7.0 入门(一)">SQL Server 7.0
入门(...</A>[<FONT color=red>7239</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1540"
target=_top title=PHP4实际应用经验篇(1)>PHP4实际应用经验篇(1)</A>[<FONT
color=red>7135</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1536"
target=_top
title=无组件文件上传代码实例(支持多文件上传及文件和input域混合上传)>无组件文件上传代码实例(支持多文件上...</A>[<FONT
color=red>6029</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=2557"
target=_top title=树型结构在ASP中的简单解决>树型结构在ASP中的简单解决</A>[<FONT
color=red>5757</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1545"
target=_top title=PHP4实际应用经验篇(6)>PHP4实际应用经验篇(6)</A>[<FONT
color=red>5599</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=2563"
target=_top title=一个老个写的无组件上传>一个老个写的无组件上传</A>[<FONT
color=red>5014</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1542"
target=_top title=PHP4实际应用经验篇(3)>PHP4实际应用经验篇(3)</A>[<FONT
color=red>4731</FONT>]<BR></LI></TD>
<TD class=p4 vAlign=top width="50%">
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2642">用ASP和SQL实现基于Web的事件日历</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=1947">带日期标注的日历控件</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=1505">一个非常精彩的日历程序</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=1471">一个非常精彩的日历程序</A><BR></LI></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR></TBODY></TABLE>
<TD bgColor=#297dff width=1> </TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD bgColor=#297dff height=1><SPACER type="block"
width="1"></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle height=30></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle class=p2 width="100%">
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle class=p2 width="100%">
<P align=center><A
href="http://www.aspsky.net/produce/index.asp">客户服务</A> -- <A
href="http://www.aspsky.net/aspads.asp">广告合作</A> -- <A
href="http://www.aspsky.net/about.asp">关于本站</A> -- <A
href="http://www.aspsky.net/tell.asp">联系方法</A><BR><BR>动网先锋版权所有 <FONT
face=Verdana, size=1 Arial, Helvetica, sans-serif>Copyright ©
2000-2001 <B>AspSky<FONT color=#cc0000>.Net</FONT></B>, All Rights
Reserved .</FONT>
</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -