<!– blog日历表开始 –>
<script language="javascript">
var diarydays="";//"<2004-07-26><2004-07-25><2004-07-22><2004-07-21><2004-07-20><2004-07-19><2004-07-18><2004-07-16><2004-07-15><2004-07-14><2004-07-13><2004-07-12><2004-07-11><2004-07-10><2004-07-09><2004-07-08><2004-07-06><2004-07-05><2004-07-04><2004-07-03><2004-07-02><2004-07-01><2004-06-30><2004-06-27><2004-06-26>";
</script>
<style>
.calendarbigborder { font-family: "arial", "helvetica", "sans-serif", "宋体"; text-decoration: none; width: 170; background-color: #ffffff; font-size: 9pt;border:1px dotted #999; }
.calendartd { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #000000; background-color: #eeeeee; height: 18px; width: 11%; text-align: center;}
.calendarminput { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; text-decoration: none; background-color: #ffffff; height: 15px; border: 1px solid #666666; width: 19px; color: #0099ff;}
.calendaryinput { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #0099ff; text-decoration: none; background-color: #ffffff; height: 15px; width: 34px; border: 1px solid #666666;}
.calendarmonthtitle { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; font-weight: normal; height: 24px; text-align: center; color: #333333; text-decoration: none; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-bottom-style: none; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999;}
.calendarnow { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; font-weight: bold; color: #000000; background-color: #c0c9d3; height: 18px; text-align: center;}
.calendardaysat { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #333333; text-decoration: none; background-color: #eeeeee; text-align: center; height: 18px; width: 12%;}
.calendardaysun { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #333333; text-decoration: none; background-color: #eeeeee; text-align: center; height: 18px; width: 12%;}
.calendarlink { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; font-weight: normal; color: #333333; text-decoration: none; background-color: #e7e7f6; text-align: center; height: 18px;}
.categorytxt { font-family: "arial", "helvetica", "sans-serif", "宋体"; font-size: 9pt; line-height: 23px; color: #333333; text-decoration: none;}
.categorytable { border-right-width: 1px; border-bottom-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: none; border-right-color: #000000; border-bottom-color: #000000; border-top-width: 1px; border-top-style: solid; border-top-color: #71b99c;}
</style>
<script language="javascript">
var months = new array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二");
var daysinmonth = new array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
var days = new array("日","一", "二", "三","四", "五", "六");
var classtemp;
var calendarhover="calendarhover";
var today=new gettoday();
var year=today.year;
var month=today.month;
var newcal;
//得到某月天数
function getdays(month, year)
{ if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28;
else
return daysinmonth[month];
}
//得到当天时间信息
function gettoday()
{ this.now = new date();
this.year = this.now.getfullyear();
this.month = this.now.getmonth();
this.day = this.now.getdate();
}
//生成日历
function calendar()
{ newcal = new date(year,month,1); //当前月的第一天
today = new gettoday();
var day = -1; //用来判断日历中是否为当天
var startday = newcal.getday(); //当月开始时间
var endday=getdays(newcal.getmonth(), newcal.getfullyear());//当月结束时间
var daily = 0; //用来生成日历中的天数值
if ((today.year == newcal.getfullyear()) &&(today.month == newcal.getmonth()))
day = today.day;
var caltable = document.all.caltable.tbodies.calendar; //得到日历表格的集合
var intdaysinmonth =getdays(newcal.getmonth(), newcal.getfullyear()); //得到当月天数
//生成日历
for (var intweek = 0; intweek < caltable.rows.length;intweek++)
for (var intday = 0;intday < caltable.rows[intweek].cells.length;intday++)
{
var cell = caltable.rows[intweek].cells[intday]; //得到单元袼
//生成字符串用于判断当天是否有日志
var montemp=(newcal.getmonth()+1)<10?("0"+(newcal.getmonth()+1)):(newcal.getmonth()+1);
if ((intday == startday) && (0 == daily)){ daily = 1;}
var daytemp=daily<10?("0"+daily):(daily);
var d="<"+newcal.getfullyear()+"-"+montemp+"-"+daytemp+">";
//选择样式
if(day==daily)
cell.classname="calendarnow";
else if(diarydays.indexof(d)!=-1)
cell.classname="calendarlink";
else if(intday==6)
cell.classname = "calendardaysat";
else if (intday==0)
cell.classname ="calendardaysun";
else
cell.classname="calendartd";
//生成值
if ((daily > 0) && (daily <= intdaysinmonth))
{ cell.innertext = daily;
daily++;
}
else
cell.innertext = "";
}
document.all.year.value=year;
document.all.month.value=month+1;
}
function submonth()
{
if ((month-1)<0)
{
month=11;
year=year-1;
}
else
{
month=month-1;
}
calendar();
}
function addmonth()
{
if((month+1)>11)
{
month=0;
year=year+1;
}
else
{
month=month+1;
}
calendar();
}
//得到响应事件
function getdiary()
{
var mon=(newcal.getmonth()+1)<10?("0"+(newcal.getmonth()+1)):(newcal.getmonth()+1);
var day=event.srcelement.innertext<10?("0"+event.srcelement.innertext):(event.srcelement.innertext);
var d="<"+newcal.getfullyear()+"-"+mon+"-"+day+">";
if ("td" == event.srcelement.tagname)
if (("" != event.srcelement.innertext)&&(diarydays.indexof(d)!=-1))
{
diary.location="/chensheng913/archive/"+newcal.getfullyear()+"/"+mon+"/"+day+".aspx";
window.location.href = diary.location;
}
}
function setdate()
{
if (document.all.month.value<1||document.all.month.value>12)
{
alert("月的有效范围在1-12之间!");
return;
}
year=math.ceil(document.all.year.value);
month=math.ceil(document.all.month.value-1);
calendar();
}
</script>
<table border="0" cellpadding="0" cellspacing="1" class="calendarbigborder" id="caltable" width="200">
<thead>
<tr align="center" valign="middle">
<td colspan="7" class="calendarmonthtitle">
<input name="year" type="text" class="calendaryinput" size="3" maxlength="4" onkeydown="if (event.keycode==13){setdate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,)" onpaste="this.value=this.value.replace(/[^0-9]/g,)"> 年
<input name="month" type="text" class="calendarminput" size="1" maxlength="2" onkeydown="if (event.keycode==13){setdate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,)" onpaste="this.value=this.value.replace(/[^0-9]/g,)"> 月 <a onclick="addmonth()" href="javascript:;">下月</a> : <a onclick="submonth()" href="javascript:;">上月</a></td>
</tr>
<tr align="center" valign="middle">
<script language="javascript">
document.write("<td class=calendardaysun id=diary>" + days[0] + "</td>");
for (var intloop = 1; intloop < days.length-1;
intloop++)
document.write("<td class=calendartd id=diary>" + days[intloop] + "</td>");
document.write("<td class=calendardaysat id=diary>" + days[intloop] + "</td>");
</script>
</tr>
</thead>
<tbody border=1 cellspacing="0" cellpadding="0" id="calendar" align=center onclick="getdiary()" onmouseup=document.selection.empty() oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()>
<script language="javascript">
for (var intweeks = 0; intweeks < 6; intweeks++) {
document.write("<tr style=cursor:hand>");
for (var intdays = 0; intdays < days.length;intdays++)
document.write("<td class=calendartd onmouseover={classtemp=this.classname;this.classname=calendarhover} onmouseout=this.classname=classtemp></td>");
document.write("</tr>");
}
</script>
</tbody>
</table>
<script language="javascript">
calendar();
</script>
<!– blog日历表结束 –>
日历-ASP教程,ASP应用
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 日历-ASP教程,ASP应用
相关推荐
- 暂无文章
