网站首页
关于深山
客户案例
业务范围
联系深山
网络投票系统
企业网站建设
旅行社网站建设
小程序
留言板
技术文章
许愿墙(qq爱墙)
技术首页
百度小程序开发
微信小程序开发
微信公众号开发
uni-app
asp函数库
ASP
asp.net
DIV+CSS
HTML
SEO搜索引擎忧化
下载类信息
个人空间
代码生成
电商
python
页面特效
表格特效
导航菜单
图形特效
表单特效
时间日期
色彩类别
链接特效
网页特效
系统硬件
网站公告
网页学习
技术类文章
网站类信息
订阅本栏目 RSS
您所在的位置:
深山工作室
>
时间日期
> 正文
特别简洁的简单JavaScript日历及说明
www.wxwdesign.cn 2010/6/28 23:30:14 深山行者 字体:
大
中
小
浏览 13289
以下为详细代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body{ margin:0px; padding:0px; font-size:12px; line-height:22px; font-family:tahoma,"宋体",Simsun, "Microsoft YaHei","Arial Unicode MS", Mingliu, Arial, Helvetica;} table{ background:#999999; width:600px; margin:0px auto; text-align:center;} table td{ background:#FFFFFF;} table th{ background:#CCCCCC; width:84px;} .calendar{ width:600px; margin:2px auto; height:auto; overflow:hidden; text-align:center;} .calendar a{text-decoration:none; font-size:14px; display:inline-block; width:30px;} .calendar a:hover{ background:#BFBFBF;} .calendar .left{ float:left; width:100px;} .calendar .now_month{ float:left; width:400px;} .calendar .right{ float:right; width:100px;} .red{ color:#FF0000;} .today{ background:#cccccc;} .copyright{ width:600px; margin:16px auto;} </style> <script type="text/javascript"> /* power By: http://www.wxwdesign.cn Author: 流水涵清 */ //创建calendar类 function calendar(y,m){ var c=new Date(y,m,1,0,0,0,0); //当月第一天 this.daynum=getMonthDays(m+1,y); //获得当月的天数 this.firstday=c.getDay(); //当月第一天星期几 } //获取某一月的天数 function getMonthDays(m,y){ var d=[31,28,31,30,31,30,31,31,30,31,30,31]; if(m==2){if(check(y)){return 29;}else{return 28;}}else{return d[m-1];} function check(year){ if(year%100==0){if(year%400==0){return true;}else{return false;}}else{if(year%4==0){return true;}else{return false;}} } } //获取农历 function GetNL(y,m,d){ var t=new Date(y,m,d,0,0,0,0); return CnDateofDateStr(t); } function DaysNumberofDate(DateGL){return parseInt((Date.parse(DateGL)-Date.parse(DateGL.getFullYear()+"/1/1"))/86400000)+1;} function CnDateofDate(DateGL){ var CnData=new Array( 0x16,0x2a,0xda,0x00,0x83,0x49,0xb6,0x05,0x0e,0x64,0xbb,0x00,0x19,0xb2,0x5b,0x00, 0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02, 0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00, 0x86,0xe4,0xae,0x05,0x11,0xea,0x56,0x00,0x1b,0x6d,0x2a,0x00,0x88,0x5a,0xaa,0x04, 0x14,0xad,0x55,0x00,0x81,0xaa,0xd5,0x09,0x0b,0x52,0xea,0x00,0x16,0xa9,0x6d,0x00, 0x84,0xa9,0x5d,0x06,0x0f,0xd4,0xae,0x00,0x1a,0xea,0x4d,0x00,0x87,0xba,0x55,0x04 ); var CnMonth=new Array(); var CnMonthDays=new Array(); var CnBeginDay; var LeapMonth; var Bytes=new Array(); var I; var CnMonthData; var DaysCount; var CnDaysCount; var ResultMonth; var ResultDay; var yyyy=DateGL.getFullYear(); var mm=DateGL.getMonth()+1; var dd=DateGL.getDate(); if(yyyy<100) yyyy+=1900; if ((yyyy < 1997) || (yyyy > 2020)){ return 0; } Bytes[0] = CnData[(yyyy - 1997) * 4]; Bytes[1] = CnData[(yyyy - 1997) * 4 + 1]; Bytes[2] = CnData[(yyyy - 1997) * 4 + 2]; Bytes[3] = CnData[(yyyy - 1997) * 4 + 3]; if ((Bytes[0] & 0x80) != 0) {CnMonth[0] = 12;} else {CnMonth[0] = 11;} CnBeginDay = (Bytes[0] & 0x7f); CnMonthData = Bytes[1]; CnMonthData = CnMonthData << 8; CnMonthData = CnMonthData | Bytes[2]; LeapMonth = Bytes[3]; for (I=15;I>=0;I--){ CnMonthDays[15 - I] = 29; if (((1 << I) & CnMonthData) != 0 ){ CnMonthDays[15 - I]++;} if (CnMonth[15 - I] == LeapMonth ){ CnMonth[15 - I + 1] = - LeapMonth;} else{ if (CnMonth[15 - I] < 0 ){CnMonth[15 - I + 1] = - CnMonth[15 - I] + 1;} else {CnMonth[15 - I + 1] = CnMonth[15 - I] + 1;} if (CnMonth[15 - I + 1] > 12 ){ CnMonth[15 - I + 1] = 1;} } } DaysCount = DaysNumberofDate(DateGL) - 1; if (DaysCount <= (CnMonthDays[0] - CnBeginDay)){ if ((yyyy > 1901) && (CnDateofDate(new Date((yyyy - 1)+"/12/31")) < 0)){ ResultMonth = - CnMonth[0];} else {ResultMonth = CnMonth[0];} ResultDay = CnBeginDay + DaysCount; } else{ CnDaysCount = CnMonthDays[0] - CnBeginDay; I = 1; while ((CnDaysCount < DaysCount) && (CnDaysCount + CnMonthDays[I] < DaysCount)){ CnDaysCount+= CnMonthDays[I]; I++; } ResultMonth = CnMonth[I]; ResultDay = DaysCount - CnDaysCount; } if (ResultMonth > 0){ return ResultMonth * 100 + ResultDay;} else{return ResultMonth * 100 - ResultDay;} } function CnMonthofDate(DateGL){ var CnMonthStr=new Array("零","一","二","三","四","五","六","七","八","九","十","十一","十二"); var Month; Month = parseInt(CnDateofDate(DateGL)/100); if (Month < 0){return "闰" + CnMonthStr[-Month] + "月";} else{return CnMonthStr[Month] + "月";} } function CnDayofDate(DateGL){ var CnDayStr=new Array("零", "初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"); var Day; Day = (Math.abs(CnDateofDate(DateGL)))%100; return CnDayStr[Day]; } function CnDateofDateStr(DateGL){ if(CnMonthofDate(DateGL)=="零月"){return " 请调整您的计算机日期!";}else{if((Math.abs(CnDateofDate(DateGL)))%100==1){return "<b>"+CnMonthofDate(DateGL)+"</b>";}else{return CnDayofDate(DateGL);}} } //初始化显示 function init_calendar(){ var now=new Date(); var year=now.getFullYear(); var month=now.getMonth(); var day=now.getDay(); var date=now.getDate(); var today=[year,month,date]; var c=document.getElementById("calendar"); var show=document.getElementById("show"); var a=c.getElementsByTagName("a"); var div=c.getElementsByTagName("div"); var ca=new calendar(year,month); a[1].onclick=function(){month--;if(month<0){year--;month=11;};ca=new calendar(year,month);show_calendar();} a[2].onclick=function(){month++;if(month>11){year++;month=0;};ca=new calendar(year,month);show_calendar();} a[0].onclick=function(){year--;ca=new calendar(year,month);show_calendar();} a[3].onclick=function(){year++;ca=new calendar(year,month);show_calendar();} function show_calendar(){ div[1].innerHTML=year+"年"+(month+1)+"月"; var f="<table border=\"0\" cellspacing=\"1\">"; f+="<tr><th scope=\"col\" class='red'>日</th><th scope=\"col\">一</th><th scope=\"col\">二</th><th scope=\"col\">三</th><th scope=\"col\">四</th><th scope=\"col\">五</th><th scope=\"col\" class='red'>六</th></tr>"; f+="<tr>"; if(ca.firstday>0){for(var i=0;i<ca.firstday;i++){f+="<td></td>";}} for(var i=ca.firstday,j=1;j<ca.daynum+1;i++,j++){ if(i%7==0&&i>0){f+="</tr><tr>";} if(today[0]==year&&today[1]==month&&today[2]==j){ if(i%7==0||(i+1)%7==0){f+="<td class='red today'>"+j+"<br />"+GetNL(year,month,j)+"</td>";}else{f+="<td class='today' >"+j+"<br />"+GetNL(year,month,j)+"</td>";} }else{ if(i%7==0||(i+1)%7==0){f+="<td class='red'>"+j+"<br />"+GetNL(year,month,j)+"</td>";}else{f+="<td>"+j+"<br />"+GetNL(year,month,j)+"</td>";} } } if(7>(7-(ca.daynum+ca.firstday)%7)>0){for(var i=0;i<(7-(ca.daynum+ca.firstday)%7);i++){f+="<td></td>";}} f+="</tr></table>"; show.innerHTML=f; } show_calendar(); } window.onload=init_calendar; </script> <title>javascript_calendar</title> </head> <body> <div class="calendar" id="calendar"><div class="left"><a href="#" title="上一年"><<</a> <a href="#" title="上一月"><</a></div><div class="now_month">2009年7月</div><div class="right"><a href="#" title="下一月">></a> <a href="#" title="下一年">>></a></div></div> <div class="calendar_show" id="show"></div> </body> </html>
前一页:
黑色的非常酷的简单JavaScript日历及说明
后一页:
可以用于考试系统中试卷上交的javascript倒计时
相关阅读
网站需要SEO 基本的SEO建站要点
两个ASP中防止SQL注入式攻击
在网页标题栏上或收藏夹前面显示网站ico小图标的方法
深山旅行社网站管理系统 v1.7
巧用ASP技术保护DHTML源代码
添加一个防下载字段(长二进制数据)来防止ACCESS数据库被下载
深山文章管理系统 v1.0 bulid 090418
山西省太原夏日阳光国际旅行社
更多信息>>
栏目类别选择
百度小程序开发
微信小程序开发
微信公众号开发
uni-app
asp函数库
ASP
DIV+CSS
HTML
python
更多>>
同类信息
利用JavaScript获取现在时间日期与农历
另外的一种可以计算的倒计时效果
非常酷的javascript实现万年历功能
黑色的非常酷的简单JavaScript日历及说明
特别简洁的简单JavaScript日历及说明
可以用于考试系统中试卷上交的javascript倒计时
更多>>
最新添加文章
dw里面查找替换使用正则删除sqlserver里面的CONSTRAINT
Android移动端自动化测试:使用UIAutomatorViewer与Selenium定位元素
抖音直播音挂载小雪花 懂车帝小程序
javascript获取浏览器指纹可以用来做投票
火狐Mozilla Firefox出现:无法载入您的Firefox配置文件 它可能已经丢失 或是无法访问 问题解决集合处理办法
在Android、iOS、Windows、MacOS中微信小程序的文件存放路径
python通过代码修改pip下载源让下载库飞起
python里面requests.post返回的res.text还有其它的吗
更多>>
随机抽取信息
Appium获取手机分辨率 & 自适应设备下滑刷新
字体放大效果,字体[大][中][小]
uni-app开发表单input组件的一些规则说明自己预留使用
非常不错的支持各种浏览器的简易调色板
python错误yntaxError: Non-UTF-8 code starting with '\xd3' in file 文件.py but no encoding declared
macromedia dreamweaver 平均分布单表格宽度与高度mxp插件下载
更多标签
热门标签
遍历
网页制作
奋斗
form
深山v1.0旅行社网站管理系统
颜色
行号
文本框
黑白
flash
竖排
格式
访问量
openwin
心情
border
滚动
body
关联
function
保护眼睛的电脑色
text
网站
相册
css
网易
框架
许愿
表单
初级
vista
弹窗
数据库
文字样式
高
市
倒计时
对联
闭合
左右
底部
论坛
用户体验
禁止
标注
编辑
进度
伪类
广告
Response
免责声明:本站所有资料信息,有部分为本人原创,部分为从网络收集而来,仅供网友查看阅读所用,所有信息版权归信息所有人或所有公司所有
如果信息内容侵犯到您的版权或权益请与我们联系,经确认后我们会立即移除相关内容或链接
Copyright © 2007-2026
深山工作室
All Rights Reserved
服务QQ:
565449214
手机:
13961347334
ICP备案:
苏ICP备15019627号
苏公网安备 32070502010230号