首页
网页特效库
网页特效库
导航菜单
按钮表单
背景特效
时间日期
图片特效
鼠标特效
文本操作
窗口页面
状态栏类
警告对话
综合应用
游戏娱乐
首页
>
特效
>
时间日期
> 正文
小而强大的万年历
2011-09-29 时间日期 ℃
第一步:把如下代码加入到区域中 <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("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");*/ var days = new Array("日","一", "二", "三", "四", "五", "六"); 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(); } 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 < tableCal.rows.length;intWeek++) for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;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 <= intDaysInMonth)) { 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); } } </script>
第二步:把如下代码加入到区域中
<script LANGUAGE="JavaScript"> for (var intLoop = 0; intLoop < months.length; intLoop++) document.write("
" + months[intLoop]); </script>
<script LANGUAGE="JavaScript"> for (var intLoop = today.year-100; intLoop < (today.year + 64); intLoop++) document.write("
" + intLoop); </script>
<script LANGUAGE="JavaScript"> document.write("
" + days[0] + "
"); for (var intLoop = 1; intLoop < days.length-1; intLoop++) document.write("
" + days[intLoop] + "
"); document.write("
" + days[intLoop] + "
"); </script>
<script LANGUAGE="JavaScript"> for (var intWeeks = 0; intWeeks < 6; intWeeks++) { document.write("
"); for (var intDays = 0; intDays < days.length; intDays++) document.write("
"); document.write("
"); } </script>
<script Language="JavaScript1.2"> function Cancel() { document.all.ret.value = ""; window.close(); } </script>
相关特效代码
CSS实现区域内等比例放大缩小图片代码
07/18
按钮控制图片大小
07/18
调整图片大小的js代码
07/18
滚动鼠标滚轮控制图片大小
07/18
点击图片图片大小发生变化
06/11
点击小图显示大图片
06/11
按钮控制图片放大缩小特效
05/30
图片忽大忽小变化特效
03/31
网页代码智力小游戏
08/17
双人小游戏代码
08/17
热门特效代码
世界时间一览表
时间流水线
相当漂亮的蓝色精美日历
今天是:年月日-日期-星期几
纯JavaScript时钟
年月日-当前英文时间
小而强大的万年历
最简洁事件代码格式如:xxxx年x月
2010日历生成器
显示访问本站多久时间
推荐特效代码
年月日-当前英文时间
今天是:年月日-日期-星期几
最简洁事件代码格式如:xxxx年x月
八种风格的时间日期特效代码
常见的选择日期效果
模拟时钟