Wiki⽇历做法HTML标签:
<ul id='ul_calendar'>
<li>⽇ </li>
<li>⼀ </li>
<li>⼆ </li>
<li>三 </li>
<li>四 </li>
<li>五 </li>
<li>六 </li>
</ul>
View Code
完整HTML代码:
<table width="476" height="155" border="0" align="center" cellpadding="0" cellspacing="0"
class="cal">
<tr>
<td align="center" valign="top">
<div class="show" align="center">
<span id='month_cur'class="big"></span>
<br>
<span id='month_pre'></span>  <span id='month_next'></span></div>                            </td>
<td>
<ul id='ul_calendar'>
<li>⽇ </li>
<li>⼀ </li>
<li>⼆ </li>
<li>三 </li>
<li>四 </li>
<li>五 </li>
<li>六 </li>
</ul>
</td>
</tr>
</table>
View Code
样式(刚好7个li):
ul#ul_calendar{width: 280px; line-height: 28px}
ul#ul_calendar li {float: left;width: 40px; }
View Code
js:
<script language="JavaScript">
var months = new Array("⼀", "⼆", "三", "四", "五", "六", "七", "⼋", "九", "⼗", "⼗⼀", "⼗⼆");
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);  /* 对应12个⽉有多少天*/ var days = new Array("⽇", "⼀", "⼆", "三", "四", "五", "六");
var classTemp;
var calendarHover = "calendarHover";
var today = new getToday();
var year = ar;
var month = h;
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.day = Date();
}
/
/⽣成⽇历
function Calendar(month) {
month = month - 1;
newCal = new Date(year, month, 1); //当前⽉的第⼀天
today = new getToday();
var day = -1;  //⽤来判断⽇历中是否为当天
var startDay = Day(); //当⽉开始时间的星期数0-6
var endDay = Month(), FullYear()); //当⽉结束时间
var t = (Math.floor((startDay + endDay) / 7) + ((((startDay + endDay) % 7) > 1) ? 1 : 0));
var daily = 0;  //⽤来⽣成⽇历中的天数值
if ((ar == FullYear()) && (h == Month()))
day = today.day;
var calbox = ElementById('ul_calendar');
var intDaysInMonth = Month(), FullYear()); //得到当⽉天数
//⽣成⽇历
for (var intWeek = 0; intWeek < t; intWeek++)
for (var intDay = 0; intDay < 7; intDay++) {
if ((intDay == startDay) && (0 == daily)) { daily = 1; }
//⽣成值
if ((daily > 0) && (daily <= intDaysInMonth)) {
if (day == daily)
calbox.innerHTML += '<li><a href="#' + daily + '"><font color="#FF0000">' + daily + '</font></a></li>';
else
calbox.innerHTML += '<li><a href="#' + daily + '">' + daily + '</a></li>';
daily++;
}
else {
calbox.innerHTML += '<li> </li>';
}
}
var tem_month = (month + 1);
html ul标签
tem_month = ((month == 0) ? 12 : month);
</script>
<script language="JavaScript">
Calendar(<%=ViewData["month"]%>);
</script>
View Code
效果图:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。