javascript脚本实现日历控件

<html>

<head>

<scripttype="text/javascript" language="javascript">

             进来项目中要用到日期控件,又无先例,故而本人狠下决心,参照多方,写下这段js源码,编译,运行都通过,如有疑问,或者不知如何用,欢迎mail:

               【 zhe-jiang.he@hp.com】

          以下是src:


/**

 * add auto hide when mouse moveout

 *

 * @version 1.0.1

 * @date 2013-11-28

 * @author zhe-jiang.he@hp.com

*/

 

/**  

 * Date Picker

 * @param  inputObj  The input object want tocontain date.

 * @param  dateFormatStyle  Default DateFormatter is "yyyy-MM-dd", you could use your own defined format.

 * @param  beginDate Default value is 1990-01-01

 * @param  endDate   Default value is2020-01-01

 * @param  lang     0(English)|1(Chinese)  DefaultLanguage is 0(English).

 */

functionsetday(inputObj,dateFormatStyle,beginDate,endDate,lang){

if(null == inputObj){return null;}

newCalendar(inputObj,dateFormatStyle,beginDate,endDate,lang).show();

}

 

/**  

 * Month Picker

 * @param  inputObj  The input object want tocontain date.

 * @param  dateFormatStyle  Default DateFormatter is "yyyy-MM", you could use your own defined format.

 * @param  beginDate Default value is 1990-01

 * @param  endDate   Default value is 2020-01

 * @param  lang     0(English)|1(Chinese)  DefaultLanguage is 0(English).

 */

functionsetmonth(inputObj,dateFormatStyle,beginDate,endDate,lang){

if(null == inputObj){return null;}

newCalendar(inputObj,dateFormatStyle,beginDate,endDate,lang,"m").show();

}

 

/**

CalendarStyle

*/

Calendar.prototype.style= function(){

var strStyle = "<style type='text/css'>";

strStyle += ".calendar {font-size:12px;margin:0;padding:0px;border:1px solid #397EAE;background-color:#DBE7F2;}";

strStyle += ".calendar ul {list-style-type:none; margin:0;padding:0;vertical-align:middle;}";

strStyle += ".calendar li {float:left;}.calendarb{font-weight:bold;}";

strStyle += ".calendar .day li {height:20px;}";

strStyle += ".calendar .day li,.calendar .dateli{float:left;width:14.13%;height:20px;line-height:20px;text-align:center;}";

strStyle += ".calendar .day li{font-weight:bold;} .calendar.date li{background-color:#EDF3F9;}";

strStyle += ".calendar .monthli{float:left;width:24.8%;height:20px;line-height:20px;text-align:center;background-color:#EDF3F9;}";

strStyle += ".calendar li a{ text-decoration:none;font-family:Tahoma; font-size:11px; color:#333}";

strStyle += ".calendar li:hover {cursor:pointer;color:#f30;text-decoration:none;background-color:#EDF3F9;}";

strStyle += ".calendar .date li:hover, .calendar .monthli:hover{cursor:pointer;color:#f30;text-decoration:none;background-color:#DBE7F2;}";

strStyle += ".calendarlihover{color:#f30;text-decoration:none;background-color:#E8F2FE;}";

strStyle += ".calendar li a.hasArticle {font-weight:bold;color:#f60 !important}";

strStyle += ".lastMonthDate, .nextMonthDate{color:#bbb;font-size:11px}";

strStyle += ".selectThisYear,.selectThisMonth{text-decoration:none; margin:0px; color:#000;font-weight:bold}";

strStyle += ".calendar .LastMonth, .calendar.NextMonth{text-decoration:none; color:#000; font-size:18px; font-weight:bold;line-height:16px;}";

strStyle +=".calendarTitle{background:#EDF3F9;text-align:center;height:20px;line-height:20px;clear:both;width:100%;}";

strStyle += ".calendarTitle.mark{text-decoration:none;color:#000;font-family:Tahoma;font-size:18px;font-weight:normal;}";

strStyle += ".today{ background-color:#ffffaa;border:1px solid#f60;padding:0 1px;}";

strStyle += ".today a { color:#f30; }";

strStyle += ".calendarBottom{text-align:center;height:20px;line-height:20px;clear:both;width:100%;border-top:1pxsolid #ddd;}";

strStyle += ".calendarBottomli{float:left;height:20px;line-height:20px;font-weight:bold;text-align:center;}";

strStyle += "</style>";

return strStyle;

}

 

/**

//ClassicStyle

Calendar.prototype.style= function(){

var strStyle = "<style type='text/css'>";

strStyle += ".calendar {font-size:12px;margin:0;padding:0px;border:1px solid #397EAE;}";

strStyle += ".calendar ul {list-style-type:none; margin:0;padding:0;vertical-align:middle;}";

strStyle += ".calendar li {float:left;}.calendarb{font-weight:bold;}";

strStyle += ".calendar .day { background-color:#EDF5FF;height:20px;}";

strStyle += ".calendar .day li,.calendar .date li{ float:left;width:14.13%; height:20px; line-height:20px; text-align:center}";

strStyle += ".calendar .month li{ float:left; width:24.8%;height:20px; line-height:20px; text-align:center}";

strStyle += ".calendar li a{ text-decoration:none;font-family:Tahoma; font-size:11px; color:#333}";

strStyle += ".calendar li:hover {cursor:pointer;color:#f30;text-decoration:none;background-color:#E8F2FE;}";

strStyle += ".calendarlihover{color:#f30;text-decoration:none;background-color:#E8F2FE;}";

strStyle += ".calendar li a.hasArticle {font-weight:bold;color:#f60 !important}";

strStyle += ".lastMonthDate, .nextMonthDate{color:#bbb;font-size:11px}";

strStyle += ".selectThisYear,.selectThisMonth{text-decoration:none; margin:0px; color:#000;font-weight:bold}";

strStyle += ".calendar .LastMonth, .calendar.NextMonth{text-decoration:none; color:#000; font-size:18px; font-weight:bold;line-height:16px;}";

strStyle += ".calendarTitle{text-align:center;height:20px;line-height:20px;clear:both;width:100%;}";

strStyle += ".calendarTitle .mark{text-decoration:none;color:#000;font-family:Tahoma;font-size:18px;font-weight:normal;line-height:16px;}";

strStyle += ".today{ background-color:#ffffaa;border:1px solid#f60;padding:0 1px;}";

strStyle += ".today a { color:#f30; }";

strStyle += ".calendarBottom{text-align:center;height:20px;line-height:20

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值