>
设为首页
>
收藏本站
>
最新电影
首页
运营资讯
今日英语
图形图像
计算机技术
Asp编程
网站结构化
资源共享
休闲娱乐
访问新站
您现在的位置:
首页
=>
后台技术
=>
脚本特效
=>
时间日期
订阅本栏目
时间控件6
时间: 2007-11-01 14:03:10 阅读次数:2991
<script> String.prototype.Format = function(){ var tmpStr = this; var iLen = arguments.length; for(var i=0;i<iLen;i++){ tmpStr = tmpStr.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]); } return tmpStr; } Calendar = { //region Property today : new Date(), year : 2005, month : 8, date : 21, curPosX : 0, curPosY : 0, curCapture : null, curDay : null, //endregion //region Method display : function(o, e, d){ with(Calendar){ o = typeof(o) == "object" ? o : document.getElementById(o); if(window.event){ curPosX = document.body.scrollLeft + event.x; curPosY = document.body.scrollTop + event.y; } else{ curPosX = e.pageX; curPosY = e.pageY; } if(o.value == "" && d) o.value = d; with(document.getElementById("Calendar__")){ if(o != curCapture) { curCapture = o; if(style.display == "block"){ style.left = curPosX + "px"; style.top = curPosY + "px"; } else load(); } else{ if (style.display == "block") style.display = "none"; else load(); } } } }, load : function(){ with(Calendar){ curDay = loadDate(curCapture.value); with(curDay){ year = getFullYear(); month = getMonth() + 1; date = getDate(); } init(); } }, init : function(){ with(Calendar){ with(new Date(year, month-1, date)){ year = getFullYear(); month = getMonth() + 1; date = getDate(); setDate(1); var first = getDay(); setMonth(getMonth()+1, 0) paint(first, getDate()); } } }, paint : function(first, last){ var calendar = document.getElementById("Calendar__"); var grid = document.getElementById("dataGrid__"); var i, l; l = Math.ceil((first + last)/7); if(!document.all){ calendar.style.height = (41 + 19 * Math.ceil((first + last)/7)) + "px"; } grid.innerHTML = new Array(l*7 + 1).join("<li><a></a></li>"); with(Calendar){ var strDate = "{0}-{1}".Format(year, month); var isTodayMonth = ((year == today.getFullYear()) && (month == today.getMonth() + 1)); var isCurdayMonth = ((year == curDay.getFullYear()) && (month == curDay.getMonth() + 1)); var todayDate = today.getDate(); for(i=0;i<last;i++){ grid.childNodes[first + i].innerHTML = '<a href="{2}-{1}"{0} onclick="Calendar.setValue({1});return false">{1}</a>'.Format(((i+1) == todayDate && isTodayMonth) ? ' class="today"' : isCurdayMonth && (i+1) == curDay.getDate()?' class="curDay"':'', i + 1, strDate); } document.getElementById("dateText__").innerHTML = '<a href="' + (year-1) + '年" onclick="Calendar.turn(-12);return false" title="上一年"><<</a> <a href="上一月" onclick="Calendar.turn(-1);return false" title="上一月"><</a> ' + year + " - " + month + ' <a href="下一月" onclick="Calendar.turn(1);return false" title="下一月">></a> <a href="' + (year+1) + '年" onclick="Calendar.turn(12);return false" title="下一年">>></a>'; with(calendar){ style.left = Calendar.curPosX + "px"; style.top = Calendar.curPosY + "px"; style.display = "block"; } } }, turn : function(num){ Calendar.month += num; Calendar.date = 1; Calendar.init(); }, setValue : function(val){ with(Calendar){ curCapture.value = "{0}-{1}-{2}".Format(year, month, val); document.getElementById("Calendar__").style.display = "none"; } }, loadDate : function(op, formatString){ formatString = formatString || "ymd"; var m, year, month, day; switch(formatString){ case "ymd" : m = op.match(new RegExp("^((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})$")); if(m == null ) return new Date(); day = m[6]; month = m[5]*1; year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10)); break; case "dmy" : m = op.match(new RegExp("^(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))$")); if(m == null ) return new Date(); day = m[1]; month = m[3]*1; year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10)); break; default : break; } if(!parseInt(month)) return new Date(); month = month==0 ?12:month; var date = new Date(year, month-1, day); return (typeof(date) == "object" && year == date.getFullYear() && month == (date.getMonth()+1) && day == date.getDate())?date:new Date(); function GetFullYear(y){return ((y<30 ? "20" : "19") + y)|0;} }, toString : function(){return ["Calendar v1.0", "author:我佛山人", "email:wfsr@msn.com", "version:1.0"].join("\n");} //endregion } var __calendar_html = "<style>"; __calendar_html += "#Calendar__ {background-color:#eeeeee;width:157 !important;width:154px;position:absolute;display:none}"; __calendar_html += "#Calendar__ ul{list-style-type:none;margin-left:-38px !important;margin:0 0 0 -30px;}"; __calendar_html += "#Calendar__ ul li{display:block;width:20px;margin:1px;background-color:#fff;text-align:center;float:left;font:11px Tahoma}"; __calendar_html += "#Calendar__ ul li a{height:18px;display:block;background-color:#fff;line-height:18px;text-decoration:none;color:#333}"; __calendar_html += "#Calendar__ ul li a:hover{background:#336699;color:#FFF}"; __calendar_html += "#Calendar__ #dateText__{font:12px Tahoma;text-align:center}"; __calendar_html += "#Calendar__ #dateText__ a{font:10px Tahoma;text-decoration:none}"; __calendar_html += "#Calendar__ #head__ li a{font:bold 12px Tahoma}"; __calendar_html += "#Calendar__ #dataGrid__{}"; __calendar_html += "#Calendar__ #dataGrid__ li a:hover{background:#dedede url(/plus/calendar/check.gif) right bottom no-repeat;color:red}"; __calendar_html += "#Calendar__ #dataGrid__ .today{background:url(/plus/calendar/today.gif) center no-repeat;color:blue;}"; __calendar_html += "#Calendar__ #dataGrid__ .curDay{background:#dedede url(/plus/calendar/check.gif) right bottom no-repeat;color:blue;}"; __calendar_html += "</style>"; __calendar_html += "<div id=\"Calendar__\">"; __calendar_html += "<div id=\"dateText__\"></div>"; __calendar_html += "<ul id=\"head__\" onclick=\"return false\">"; __calendar_html += "<li><a href=\"#\">日</a></li><li><a href=\"#\">一</a></li><li><a href=\"#\">二</a></li><li><a href=\"#\">三</a></li><li><a href=\"#\">四</a></li><li><a href=\"#\">五</a></li><li><a href=\"#\">六</a></li>"; __calendar_html += "</ul>"; __calendar_html += "<ul id=\"dataGrid__\"></ul>"; __calendar_html += "</div>"; document.write(__calendar_html); </script> <input type="text" id="demo"><img src="calendar.gif" align="absmiddle" onclick="Calendar.display('demo', event, '1980-6-15')"><br> <input type="text" id="demo1"><img src="calendar.gif" align="absmiddle" onclick="Calendar.display('demo1', event)">
提示:您可以先修改部分代码再运行
站内搜索
:
标题
内容
下一篇
时间控件7(梅花雨控件)
上一篇
日期输入控件
本栏目最新
栏目最新列表
符合标准的时间选择控件
js选择日期(可以选择开始结束时间)
带对勾的日期选择控件 蓝色
蓝色日历控件 只能选择日期
10秒倒计时的JS代码
网站优化策划
栏目最新列表
增加网站外链的快速方法
网站上线前必做的30个检查
新的友情链接参考标准(没有google的PR情况
优化Google的AdSense广告的五个工具
王通讲SEO八大基础
站点最新
站点最新列表
微博推广的一些技巧
xhEditor v1.1.7 发布,
收集的一些轻量级非常实
50个新鲜兼容最新版本的
javascript中cookie的设
Excel中出现#VALUE!、#D
jquery插件:飞飞表情插件
十个使用HTML5开发的精彩
支持HTML5的浏览器有哪些
飞妮莫属:漫画:如何写出
历史最热10条信息
MIME介绍 及
[
1
] [
2
] [
3
]
巧用Google和迅雷来下载
Transact SQL 常
[
1
] [
2
]
VIA Rhine II Fast Ethe
电脑常用端
[
1
] [
2
] [
3
]
Do you get a kick out
十道羊皮卷 欣赏+mp3版+
每日一句:A friend and
每日一句:Theres no tu
经典__悟透JavaScript
相关文章
WIN 2003系统时间24
格式化时间(显示)函
在查询分析器中 查看
鼠标跟随的日期时间
状态栏滚动时间
多种时间显示格式
退出时显示访问时间
记算几天后的日期时
时间跳动器
带开关的表单时间显
相关专题
相关专题列表
符合标准的时间选择控件
js选择日期(可以选择开始
带对勾的日期选择控件 蓝
蓝色日历控件 只能选择日
日期,时间选择输入控件
日期输入控件8
时间控件7(梅花雨控件)
时间控件6
日期输入控件5(选择日期
日期输入控件4(黄色)
伟哥博客
西安房产
123最新电影
三四六四
关于站点
|
免责声明
|
联系站长
|
网站地图
|
陕ICP备07002804号
WEB技术QQ交流群:72840059
©2007 ffasp.com. 版权所有