dateSelecter.html<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>选择日期</title>
<style type="text/css">
<!--
a:link {text-decoration: none }
a:visited {text-decoration: none}
-->
</style>
<script src="date.js"></script>
</head>
<body bgcolor="#EFEFDE"><CENTER><BR>
<FONT SIZE="4">选择日期</FONT><BR><BR>
<script>
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var day=now.getDate();
month++;
document.write("<select id=selYear onchange=checkDate() >");
for (tmp=1999;tmp<2007;tmp++)
document.write("<option value='"+tmp+"'>"+tmp+"</option>");
document.write("</select>&nbsp;年&nbsp;");document.write("<select id=selMonth onchange=checkDate()>");
for (tmp=1;tmp<13;tmp++)
document.write("<option value='"+tmp+"'>"+tmp+"</option>");
document.write("</select>&nbsp;月<BR><BR>");document.write("<table >");window.selYear.value=year;
window.selMonth.value=month;
for (tmp1=1;tmp1<7;tmp1++)
{
document.write("<tr>");
for (tmp2=1;tmp2<8;tmp2++)
{
tmp3=tmp1*7+tmp2-7;
if (tmp3<10) tmp3="0"+tmp3;
document.write("<td id=tmptd></td>");
}
document.write("</tr>");
}
document.write("</table>");
checkDate();
function checkDate()
{
//每次改变了年、月时生成新的月历tmpyear=window.selYear.value;
tmpmonth= window.selMonth.value;
tmpdate=new Date(tmpyear,tmpmonth-1,1);
tmpday = tmpdate.getDay();//判断第一天是星期几
tmpday2=new Date(tmpyear,tmpmonth,1).getDay();//判断下个月第一天是星期几for (tmp=0;tmp<tmpday;tmp++)
window.tmptd[tmp].innerText="";for (tmp=1;tmp<33;tmp++)
{
if ( tmp>27 && new Date(tmpyear,tmpmonth-1,tmp).getDay()==tmpday2)//判断是否已经到了下个月
for (tmp=tmp;tmp<37;tmp++)
window.tmptd[tmpday+tmp-1].innerText="";
else if  (tmpyear == new Date().getYear() && tmpmonth == new Date().getMonth()+1 &&  tmp == new Date().getDate())
window.tmptd[tmpday+tmp-1].innerHTML="<a href='#' onMouseOver=overDate("+tmp+") onclick=selectdate("+tmp
+") style='font-size:19 ; color:#FF0000'>"+tmp+"</a>";
else
window.tmptd[tmpday+tmp-1].innerHTML="<a href='#' onMouseOver=overDate("+tmp+") onclick=selectdate("+tmp+") >"+tmp+"</a>";
}}
function selectdate(tmp)
{
tmpstr=window.selYear.value+"-"+ window.selMonth.value + "-"+tmp;
    dialogArguments.selectdate(tmpstr,dialogArguments.event.srcElement.to);
    window.close();
}
function overDate(tmp)
{
tmp2 = window.selMonth.value -1;
if (tmp2 < 10) tmp2 = "0"+tmp2;
tmpstr=window.selYear.value+tmp2+tmp;
window.tmpdiv.innerHTML = time(tmpstr);
}</script>
<div id="tmpdiv">
<SCRIPT language=javascript>document.write(time());overDate(1);
</SCRIPT>
</div>
</CENTER>
</body>
</html>
test.html:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<input type=text id=testtext ><BR>
<button onClick="showModalDialog('dateSelecter.html',window)">test</button>
<script>
function selectdate(tmpstr)
{
window.testtext.value=tmpstr;}
</script></body>
</html>
以前写的一个东西,日期格式有点不同,你可以自己改一下。

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/726/726705.xml?temp=.5616266
      

  2.   

    -- test.htm ----清双击--><input type=text value="2002-06-03" style="behavior:url(inDate.htc)" size=12>-- inDate.htc --
    <PUBLIC:COMPONENT NAME="inDate.htc" URN="">
    <PUBLIC:PROPERTY NAME="htcPath"/>
    <PUBLIC:ATTACH event="ondblclick" handler="do_dblclick" /> <SCRIPT language="JavaScript"> 
    var msDefaultvalue = this.value;
    function do_dblclick(){
    var lsWin = "dialogWidth:285px;dialogHeight:230px;center:1;resizable:no;scroll:0;help:0;status:0";
    var lonewWin = window.showModalDialog("Calendar.htm",this,lsWin);
    }
    </SCRIPT> 
    </PUBLIC:COMPONENT>
    -- Calendar.htm --
    <HTML xmlns:IE><HEAD>
    <TITLE>日期选择</TITLE>
    <STYLE>
    @media all 
    {
      IE\:Calendar 
      {
        behavior: url(calendar.htc) ;
        width : 33%;
      }
    }
      A:link { color:#003399; text-decoration:none; }
      A:visited { color:#6699CC; text-decoration:none; }
      A:hover { text-decoration:underline; }
    input {
    font:menu;
    border-left:1px solid  window;
    border-right:1px solid window;
    border-top:1px solid window;
    border-bottom:1px solid window;
    }
    </STYLE>
    </HEAD>
    <BODY BGCOLOR=#CCCCCC TEXT=#000000 onload="init()">
    <IE:Calendar id="cal" style="width :100% ; height :180; border : 1px solid black;"> </IE:Calendar>
    <fieldset><div align="right">
    <input type="button" onclick="isNow()" value="选择今天"> 
    <input type="button" onclick="cancel()" value="取消"> 
    <input onclick="enter()" type="button"  value="确定">
    </div></fieldset>
    <script language="javascript">
    function init(){
    lsDate = dialogArguments.value;
    var loDate  = lsDate.split("-");
    if (loDate.length!=3) return false; 
    var liYear  = parseInt(loDate[0]);
    var liMonth = parseInt(loDate[1]);
    var liDay   = parseInt(loDate[2]);
    if ((loDate[0].length>4)||(loDate[1].length>2)||(loDate[2].length>2)) return false;
    if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay)) return false;
    if ((liYear<1900)||(liYear>3000)) return false;
    if ((liMonth>12)||(liMonth<=0))   return false;
    if (Date_getDay(liYear,liMonth)<liDay) return false;
    cal.value = liDay + "/" + liMonth + "/" + liYear;
    }function Date_getDay(aiYear,aiMonth){
    var loDay = [0,31,28,31,30,31,30,31,31,30,31,30,31];
    if (aiYear%4==0) loDay[2] = 29;
    return loDay[aiMonth];
    }function isNow(){
    dialogArguments.value = new Date().getYear() + "-" + (new Date().getMonth()+1) + "-" + new Date().getDate();
    window.close();
    }function enter(){
    dialogArguments.value = cal.year + "-" + cal.month + "-" + cal.day;
    window.close();
    }
    function cancel(){
    window.close();
    }
    </script>
    </BODY>
    </HTML>-- 还有一个文件calendar.htc 太大123KB,是微软的东东--
      

  3.   

    就是:
    http://msdn.microsoft.com/downloads/samples/internet/behaviors/library/calendar/calendar.htm
    把里面的calendar.htc down下来,把里面的字改成中文就可以了。
      

  4.   

    支持IE5.0以上,图标自己做吧。<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    <script language=javascript>
    /*********** class calendar ************/
    //类:日历
    //事例 var oDate = new calendar("oDate","2002-1-1 23:59:59")
    var m_visibleCalendar;
    function calendar(id,initDate,width) {
    if (width) {
    } else {
    width = "116px";
    }
    this.id = id;
    var today = new Date();
    var year;
    var month;
    var date; this.Date = myDate_ParseDate(initDate);
    var months = Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
    var weekdays = Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
    //style
    document.write("<style type='text/css'>")
    document.write(".Calendar_Day_Selected {font-size:9pt;cursor:hand;vertical-align:center;background:white;text-align:center;background-image:url(../images/common/label38x14.gif);}")
    document.write(".Calendar_Day_Today {font-size:9pt;cursor:hand;vertical-align:center;text-align:center;background-image:url(../images/common/label38x14_2.gif);background-repeat:no-repeat;}")
    document.write(".Calendar_Day_Holiday {font-size:9pt;cursor:hand;background:red;vertical-align:center;text-align:center}")
    document.write(".Calendar_Day_Normal {font-size:9pt;cursor:hand;vertical-align:center;text-align:center}")
    document.write(".Calendar_Day_Other {font-size:9pt;cursor:hand;vertical-align:center;text-align:center;text:#c0c0c0}")
    document.write(".Calendar_Text {font-size:10pt;background-color:#c0c0c0;vertical-align:center;text:#ffffff;text-align:center}")
    document.write("</style>")
    //时间输入框
    document.write("<table cellspacing=0 cellpadding=0 border=0 id=" + id + " style='layer-out:fixed'>")
    document.write("<tr><td style='height:16px;border-bottom:inset 1px;border-top:inset thin white;border-left:inset thin white;border-right:inset 1px;'>")
    document.write("<input id=txtDate type=text style='border:0;z-index:0;font-size:9pt;width:" + width + ";' onkeydown='" + id + ".entDateArea();' onclick='" + id + ".selDateArea()' onblur='" + id + ".setDateArea()'>")
    document.write("<input style='height:16px;width:20px;background-image: url(../images/common/dropdown.gif); background-repeat: no-repeat; background-position: center center;' type=button onclick='" + id + ".showCalendar();this.blur();'>")
    // document.write("<input type=text id=txtDate>");
    document.write("</td></tr>")
    //下拉式时间选单
    document.write("<tr><td id=tdCalendar style='display:none;'>")
    document.write("<table onclick='event.cancelBubble=true;' cellspacing=0 cellpadding=0 border=0 align=center width=268px height=135px style='position:absolute;table-layout:fixed;border-left:1 inset;border-top:1 inset;border-bottom:1 inset black;border-right:1 inset black;' bgcolor=white>")
    document.write("<tr height=24px bgcolor=#e0e0e0>")
    document.write("<td width=134px>")
    document.write("<select id=selMonth onchange='" + id + ".setMonth();' style='width:100%'>")
    for (var i=0; i<12; i++) {
    document.write("<option>" + months[i] + "</option>")
    }
    document.write("</select>")
    document.write("</td>")
    document.write("<td width=120px align=left><input maxlength=4 border=0 id=txtYear disabled=true style='width:100%'></td>")
    document.write("<td>")
    document.write("<table height=100% cellspacing=0 cellpadding=0 border=0 align=center>")
    document.write("<tr><td><input type='button' style='font-size:6.5pt;height:10px;width:11px;background-image:url(../images/arrow/arrow_up11x9.gif); background-repeat: no-repeat; background-position: center center;' onclick='" + id + ".setYear(1);this.blur();'></td></tr>")
    document.write("<tr><td></td></tr>")
    document.write("<tr><td><input type='button' style='font-size:6.5pt;height:10px;width:11px;background-image:url(../images/arrow/arrow_down11x9.gif); background-repeat: no-repeat; background-position: center center;' onclick='" + id + ".setYear(-1);this.blur();'></td></tr>")
    document.write("</table>")
    document.write("</td></tr>")
    document.write("<tr valign=top>")
    document.write("<td colspan=3>")
    document.write("<table width=100% id=monthlyCalendar cellspacing=0 cellpadding=0 border=0 align=center>")
    document.write("<tr style='font-family:宋体;background-color:#ffffff;color:#d0d0d0'>");
    for (var i=0;i<7;i++) {
    document.write("<td width=38 style='font-size:9pt;border-top:2px solid white;border-bottom:1px solid black'>" + weekdays[i] + "</td>")
    }
    document.write("</tr>")
    for (var i=0;i<6;i++) {
    document.write("<tr height=12px width=100%>");
    for (var j=0;j<7;j++) {
    document.write("<td onclick=" + id + ".setDay(this.innerText)></td>");
    }
    document.write("</tr>");
    }
    document.write("<tr><td colspan=7 onclick='" + id + ".setDay(new Date());' style='font-size:9pt;cursor:hand;font-weight:bold;'><img height=14px src=../images/common/label38x14_2.gif>")
    document.write("<span id=spnToday>")
    document.write("&nbsp;&nbsp;今天:" + today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate())
    document.write("</span></td></tr><tr><td colspan=7></td></tr></table></td></tr></table></td></tr></table>") this.getValue = calendar_getValue;
    this.drawMonthlyCalendar = calendar_drawMonthlyCalendar;
    this.selDay = calendar_selDay;
    this.setDateArea = calendar_setDateArea;
    this.entDateArea = calendar_entDateArea;
    this.selDateArea = calendar_selDateArea;
    this.showCalendar = calendar_showCalendar;
    this.hiddenCalendar = calendar_hiddenCalendar;
    this.setDay = calendar_setDay;
    this.setMonth = calendar_setMonth;
    this.setYear = calendar_setYear;
    this.makeDate = calendar_makeDate; var rootNode = document.all(id);
    this.txtDate = rootNode.all("txtDate");
    this.tdCalendar = rootNode.all("tdCalendar");
    this.yearNode = rootNode.all("txtYear");
    this.monthNode = rootNode.all("selMonth");
    this.monthlyCalendar =  rootNode.all("monthlyCalendar");
    this.todayNode = rootNode.all("spnToday");
    this.txtDate.value = this.getValue();
    this.txtDate.blur();
    }
      

  5.   

    function calendar_getValue() {
    return myDate_parseString(this.Date);
    }
    /*操作日历的时间栏*/
    function calendar_entDateArea() {
    if (event) {
    event.returnValue = false;
    var keyCode = event.keyCode;
    //keycode: 37.← 38.↑ 39.→ 40.↓
    if ((keyCode>=37 && keyCode <41) || (keyCode>=48 && keyCode<58) || (keyCode>=96 && keyCode<106)) {
    if ((this.keyDownCount)>0) {
    var cursorPos = getCursorPosInTextRange(this.txtDate);
    var count;
    var startPos;
    var isSetDate = false;
    if (cursorPos<5) {
    startPos = 0;
    count = 4;
    } else if (cursorPos<8) {
    startPos = 5;
    count = 2;
    } else if (cursorPos<11) {
    startPos = 8;
    count = 2;
    } else if (cursorPos<14) {
    startPos = 11;
    count = 2;
    } else if (cursorPos<16) {
    startPos = 14;
    count = 2;
    } else if (cursorPos<20) {
    startPos = 16;
    count = 2;
    }
    var dateStr = this.txtDate.value;
    var selStr = dateStr.substr(startPos,count);
    if ((keyCode==37)) {//如果 37.←, 向前移位
    startPos = startPos - 3;
    if (startPos<5) {
    startPos = 0;
    count = 4;
    }
    this.makeDate(dateStr,false)
    this.keyDownCount = count;
    } else if (keyCode==38) {//如果 38.↑
    selStr = parseInt(selStr,10) + 1;
    selStr = "0000" + selStr;
    selStr = selStr.substr(selStr.length-count,count);
    dateStr = dateStr.substr(0,startPos) + selStr + dateStr.substr(startPos+count);
    this.keyDownCount = count;
    this.makeDate(dateStr,true)
    } else if (keyCode==39) {//如果 39.→,向后移位
    startPos = startPos + 3;
    if (startPos>2 && startPos<8) {
    startPos = 5;
    count = 2;
    } else if (startPos>16) {
    startPos = 16;
    }
    this.makeDate(dateStr,false)
    this.keyDownCount = count;
    } else if (keyCode==40) {//如果 40.↓
    selStr = parseInt(selStr,10) - 1;
    if (startPos==11) {
    selStr = (24 + selStr) % 24;
    } else if (startPos==14 || startPos==16) {
    selStr = (60 + selStr) % 60;
    }
    selStr = "0000" + selStr;
    selStr = selStr.substr(selStr.length-count,count);
    dateStr = dateStr.substr(0,startPos) + selStr + dateStr.substr(startPos+count);
    this.keyDownCount = count;
    this.makeDate(dateStr,true)
    } else {//如果输入的是数字,重新构造字符串
    var num;
    if (keyCode>=48 && keyCode<58) {
    var num = keyCode - 48;
    } else if (keyCode>=96 && keyCode<106) {
    var num = keyCode - 96;
    }
    if (this.keyDownCount==count) {
    selStr = "0000";
    }
    selStr = selStr + num;
    selStr = selStr.substr(selStr.length-count,count);
    dateStr = dateStr.substr(0,startPos) + selStr + dateStr.substr(startPos+count);
    this.keyDownCount--;
    if (this.keyDownCount==0) {
    this.makeDate(dateStr,false);
    this.keyDownCount = count;
    } else {
    this.txtDate.value = dateStr;
    }
    }
    selCharsInTextRange(this.txtDate,startPos,count);
    }
    }
    }
    }
    function calendar_selDateArea() {
    var cursorPos = getCursorPosInTextRange(this.txtDate);
    var count;
    var startPos;
    if (cursorPos<5) {
    startPos = 0;
    count = 4;
    } else if (cursorPos<8) {
    startPos = 5;
    count = 2;
    } else if (cursorPos<11) {
    startPos = 8;
    count = 2;
    } else if (cursorPos<14) {
    startPos = 11;
    count = 2;
    } else if (cursorPos<16) {
    startPos = 14;
    count = 2;
    } else if (cursorPos<20) {
    startPos = 16;
    count = 2;
    }

    if (this.keyDownCount!=0) {
    this.setDateArea();
    }
    this.keyDownCount = count;
    selCharsInTextRange(this.txtDate,startPos,count);
    }
    function calendar_setDateArea() {
    var date = this.makeDate(this.txtDate.value,false);
    if (date) {
    this.Date = date;
    }
    this.txtDate.innerText = this.getValue();
    }
    function calendar_showCalendar() {
    event.cancelBubble=true;
    if (m_visibleCalendar) {
    m_visibleCalendar.hiddenCalendar();
    }
    document.body.attachEvent("onclick",this.hiddenCalendar);
    this.monthNode.selectedIndex = this.Date.getMonth();
    this.yearNode.value = this.Date.getFullYear();
    this.drawMonthlyCalendar();
    this.selDay(this.Date.getDate());
    this.tdCalendar.style.display = "";
    m_visibleCalendar = this;
    }
    function calendar_hiddenCalendar() {
    m_visibleCalendar.tdCalendar.style.display = "none";
    document.body.detachEvent("onclick",m_visibleCalendar.hiddenCalendar);
    m_visibleCalendar = null;
    }
    function calendar_setDay(day){
    if (day) {
    if (typeof(day)=="object") {
    this.Date = day;
    } else {
    this.Date.setDate(parseInt(day,10));
    }
    this.txtDate.value = this.getValue();
    this.hiddenCalendar();
    }
    }
    function calendar_setMonth(){
    var dateStr = this.Date.getFullYear() + "-" + (this.monthNode.selectedIndex + 1) + "-" + this.Date.getDate() + " " + this.Date.getHours() + ":" + this.Date.getMinutes() + ":" + this.Date.getSeconds();
    this.makeDate(dateStr,true);
    this.drawMonthlyCalendar();
    }
    function calendar_setYear(increase) {
    var year = (parseInt(this.yearNode.value,10) + parseInt(increase,10)) % 10000;
    this.yearNode.value = year;
    var dateStr = year + "-" + (this.Date.getMonth() + 1) + "-" + this.Date.getDate() + " " + this.Date.getHours() + ":" + this.Date.getMinutes() + ":" + this.Date.getSeconds();
    this.makeDate(dateStr,true);
    this.drawMonthlyCalendar();
    }
    //标记选中的日期
    function calendar_selDay(day) {
    if (!day || day=="") {
    day = 1;
    } else {
    day = parseInt(day,10);
    }
    var selCell = this.monthlyCalendar.p_SelCell;
    if (selCell) {
    selCell.className = "Calendar_Day_Normal";
    }
    var month = this.monthNode.selectedIndex;
    var year = parseInt(this.yearNode.value,10);
    var firstDate = new Date(year,month,1);
    var weekday = firstDate.getDay();
    var rowIndex = Math.floor((day + weekday - 1) / 7);
    var colIndex = ((day + weekday) - 1) % 7;
    selCell = this.monthlyCalendar.rows(rowIndex+1).cells(colIndex);
    selCell.className = "Calendar_Day_Selected";
    this.monthlyCalendar.p_SelCell =selCell;
    }
    //刷新月历
    function calendar_drawMonthlyCalendar(day) {
    //清空月历
    for (var i=1;i<7; i++) {
    for (var j=0; j<7; j++) {
    var selCell = this.monthlyCalendar.rows(i).cells(j);
    selCell.innerHTML = "";
    selCell.className = "";
    }
    }
    //计算每月的天数
    var month = this.Date.getMonth();
    var year = this.Date.getFullYear();
    var firstDate = new Date(year,month,1);
    var weekday = firstDate.getDay();
    var lastDay = myDate_getLastDayInMonth(year,month);
    //填写月历
    for (var i=1;i<=lastDay;i++) {
    var rowIndex = Math.floor((i + weekday - 1) / 7);
    var colIndex = ((i + weekday) - 1) % 7
    var selCell = this.monthlyCalendar.rows(rowIndex+1).cells(colIndex);
    selCell.innerText = i;
    selCell.className  = "Calendar_Day_Normal";
    }
    var lastColumn = Math.ceil((lastDay + weekday) / 7);
    if (lastColumn<5) {
    this.monthlyCalendar.rows(5).style.display = "none";
    } else {
    this.monthlyCalendar.rows(5).style.display = "";
    }
    if (lastColumn<6) {
    this.monthlyCalendar.rows(6).style.display = "none";
    } else {
    this.monthlyCalendar.rows(6).style.display = "";
    }
    var today = new Date();
    if (this.yearNode.value==today.getFullYear() && this.monthNode.selectedIndex==today.getMonth()) {
    var date = today.getDate();
    var rowIndex = Math.floor((date + weekday - 1) / 7);
    var colIndex = ((date + weekday) - 1) % 7;
    this.monthlyCalendar.rows(rowIndex+1).cells(colIndex).className = "Calendar_Day_Today";
    }
    if (day) {
    this.selDay(day);
    }
    }
      

  6.   

    function calendar_makeDate(dateStr,increase) {
    var dates = dateStr.split(/\-|:|\s/);
    var year = parseInt(dates[0],10);
    var month = parseInt(dates[1],10)-1;
    var day = parseInt(dates[2],10);
    var hour = 0;
    var minute = 0;
    var second = 0;

    var lastDay = myDate_getLastDayInMonth(year,month);
    if (dates.length>3) {
    hour = parseInt(dates[3],10);
    }
    if (dates.length>4) {
    minute = parseInt(dates[4],10);
    }
    if (dates.length>5) {
    second = parseInt(dates[5],10);
    }
    if (year!=this.Date.getFullYear()) {
    if (increase) {
    year = year % 10000;
    }
    day = day<lastDay?day:lastDay;
    } else if (month!=this.Date.getMonth()) {
    if (increase) {
    month = (month+12) % 12;
    }
    day = day<lastDay?day:lastDay;
    } else if (day!=this.Date.getDate()) {
    if (increase) {
    day = day % lastDay;
    day = (day==0)?lastDay:day;
    }
    } else if (hour!=this.Date.getHours()) {
    hour = hour % 24;
    } else if (minute!=this.Date.getMinutes()) {
    minute = minute % 60;
    } else if (second!=this.Date.getSeconds()) {
    second = second % 60;
    }
    if (year>=0 && year<9999 && month>=0 && month<12 && day>0 && day<=lastDay) {
    this.Date = new Date(year,month,day,hour,minute,second);
    }
    this.txtDate.value = this.getValue();
    }/************************************ Date Function ************************************/
    function myDate_ParseDate(dateStr) {
    var year;
    var month;
    var date;
    if (dateStr.match(/\d\d\d\d\/|-[01]*\d\/|-[0123]*\d/ig)==null) {
    return null;
    }
    var dates = dateStr.split(/\/|-|:|\s/);
    var year = parseInt(dates[0],10);
    if (year<=0 || year >10000) {
    return null;
    }
    var month = (parseInt(dates[1],10) + 11) % 12;
    var day = parseInt(dates[2],10);
    var lastDay = myDate_getLastDayInMonth(year,month);
    if (day<=0 || day >lastDay) {
    return null;
    }
    var hour = 0;
    var minute = 0;
    var second = 0;
    if (dates.length>3) {
    hour = parseInt(dates[3],10);
    if (hour>=24 || hour<0) {
    return null;
    }
    }
    if (dates.length>4) {
    minute = (parseInt(dates[4],10)+60) % 60;
    if (minute>=60 || hour<0) {
    return null;
    }
    }
    if (dates.length>5) {
    if (second>=60 || second<0) {
    return null;
    }
    second = (parseInt(dates[5],10)+60) % 60;
    }
    return new Date(year,month,day,hour,minute,second);
    }function myDate_parseString(date) {
    if (typeof(date)!="string") {
    var dateStr="";
    dateStr = "000" + date.getFullYear() + "-";
    dateStr = dateStr.substr(dateStr.length-5);
    var tmp = date.getMonth()+1;
    if (tmp>9) {
    dateStr += tmp + "-" ;
    } else {
    dateStr += "0" + tmp + "-" ;
    }
    tmp = date.getDate();
    if (tmp>9) {
    dateStr += tmp + " " ;
    } else {
    dateStr += "0" + tmp + " " ;
    }
    tmp = date.getHours();
    if (tmp>9) {
    dateStr += tmp + ":";
    } else {
    dateStr += "0" + tmp + ":";
    }
    tmp = date.getMinutes();
    if (tmp>9) {
    dateStr += tmp + ":";
    } else {
    dateStr += "0" + tmp + ":";
    }
    tmp = date.getSeconds();
    if (tmp>9) {
    dateStr += tmp;
    } else {
    dateStr += "0" + tmp;
    }
    return dateStr;
    } else {
    return "";
    }
    }function myDate_compareDates(date1,date2) {
    if (typeof(date1)=="string") {
    date1 = myDate_ParseDate(date1);
    }
    if (typeof(date2)=="string") {
    date2 = myDate_ParseDate(date2);
    }
    date1 = date1.valueOf();
    date2 = date2.valueOf();
    if (date1>date2) {
    return 1;
    } else if (date1==date2) {
    return 0;
    } else {
    return -1;
    }
    }
    //获取某年某月的最后一天
    function myDate_getLastDayInMonth(fullYear,month) {
    var lastDay;
    if (month==1) {
    if (fullYear % 4) {
    lastDay = 28;
    } else if (fullYear % 100) {
    lastDay = 29;
    } else if (fullYear % 400) {
    lastDay = 28;
    } else {
    lastDay = 29;
    }
    }
    else if (month==3 || month==5 || month==8 || month==10) {
    lastDay = 30;
    }
    else {
    lastDay = 31;
    }
    return lastDay;
    }//获取TextRange中的光标位置
    function getCursorPosInTextRange(textArea)
    {
    var currentRange=document.selection.createRange();
    var allRange=textArea.createTextRange();
    var len=0;
    while(currentRange.compareEndPoints("StartToStart",allRange)>0)
    {
      currentRange.moveStart("character",-1);
      len++;
    }
    return len;
    }
    //选定TextRange中指定的字符串
    function selCharsInTextRange(textArea, startPosition, count)
    {
    var txtRng = textArea.createTextRange();
    if (count) {
    txtRng.moveStart("character",startPosition);
    txtRng.moveEnd("character", startPosition + count - textArea.value.length - 1);
    } else {
    txtRng.move("character",startPosition);
    }
    txtRng.expand("character");
    txtRng.select(); 
    }
    </script>
    </HEAD>
    <BODY>
    <script language=javascript>m_startDate = new calendar("m_startDate","2002-4-24 23:59:59");</script>
    </BODY>
    </HTML>
      

  7.   

    http://colorweb.go.163.com/js/index.html
    有两种方式可选。
      

  8.   

    http://colorweb.go.163.com/js/mengxhselectdate.htm
      

  9.   

    http://www.tastelife.net/
    能找到你想要的东西的!:)
      

  10.   

    请问各位高手
    prototype有什么用啊
    具体一点
      

  11.   

    说明
    用 prototype 属性提供对象的类的一组基本功能。 对象的新实例“继承”赋予该对象原型的操作。 例如,要为 Array 对象添加返回数组中最大元素值的方法。 要完成这一点,声明该函数,将它加入 Array.prototype, 并使用它。 function array_max( ){
       var i, max = this[0];
       for (i = 1; i < this.length; i++)
       {
       if (max < this[i])
       max = this[i];
       }
       return max;
    }
    Array.prototype.max = array_max;
    var x = new Array(1, 2, 3, 4, 5, 6);
    var y = x.max( );
    该代码执行后,y 保存数组 x 中的最大值,或说 6。所有 JScript 固有对象都有只读的 prototype 属性。可以象该例中那样为原型添加功能,但该对象不能被赋予不同的原型。然而,用户定义的对象可以被赋给新的原型。本语言参考中每个内部对象的方法和属性列表指出哪些是对象原型的部分,哪些不是。