<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