str += "function returnDate(n) {\n"
                                   + "      var returnDate = '';\n"
                                   + "      if (dateFormater == '') {returnDate = myDays[n];}\n"
                                   + "      else {var ss = myDays[n].split(seperator);\n"
                                   + "            var yy = parseInt(ss[0], 10);\n"
                                   + "            var mm = parseInt(ss[1], 10);\n"
                                   + "            var dd = parseInt(ss[2], 10);\n"
                                   + "            var i = 0, c = '', l;\n"
                                   + "            while (i<dateFormater.length) {\n"
                                   + "                  if ('ymd'.indexOf(dateFormater.charAt(i)) < 0) {\n"
                                   + "                        returnDate += dateFormater.charAt(i);\n"
                                   + "                        i++;\n"
                                   + "                  }\n"
                                   + "                  else {c = dateFormater.charAt(i);\n"
                                   + "                        l = 0;\n"
                                   + "                        while (i<dateFormater.length && dateFormater.charAt(i)==c) {l++; i++;}\n"
                                   + "                        if (l == 1) {returnDate += (c=='y'?yy:(c=='m'?mm:dd));}\n"
                                   + "                        else {returnDate += (c=='y'?appendZero(yy,l):(c=='m'?appendZero(mm,l):appendZero(dd,l)));}\n"
                                   + "                  }\n"
                                   + "            }\n"
                                   + "      }\n"
                                   + "      parent.document." + this.name + ".webCalendar.eventSrc.value = returnDate;\n"
                                   + "      parent.document."+this.name+".webCalendar.close();\n"
                                   + "}\n";
                  str += "function appendZero(s, l) {\n"
                                   + "      if (s == null) {s = '';}\n"
                                   + "      else {s = '' + s;}\n"
                                   + "      if (l == null) {l = 0;}\n"
                                   + "      var ss = '';\n"
                                   + "      for (var i=0; i<l; i++) {ss += '0';}\n"
                                   + "      ss += s;\n"
                                   + "      ss = ss.substring(s.length);\n"
                                   + "      return ss;\n"
                                   + "}\n";
                  str += "function dragBegin(obj) {                // 提起日历\n"
                                   + "      if (allowMove) {\n"
                                   + "            obj.setCapture();\n"
                                   + "            oldX = window.event.clientX;\n"
                                   + "            oldY = window.event.clientY;\n"
                                   + "            parentObj = parent.document." + this.name + ".webCalendar;\n"
                                   + "            yearSelect.style.display = 'none';\n"
                                   + "            monthSelect.style.display = 'none';\n"
                                   + "            isMove = true;\n"
                                   + "      }\n"
                                   + "}\n";
                  str += "function dragEnd(obj) {              // 放下日历\n"
                                   + "      if (isMove) {\n"
                                   + "            isMove = false;\n"
                                   + "            obj.releaseCapture();\n"
                                   + "      }\n"
                                   + "}\n";
                  str += "function document.onmousemove() {                 // 拖动日历\n"
                                   + "      if (isMove) {\n"
                                   + "            if (parentObj.style.left=='') {parentObj.style.left=0;}\n"
                                   + "            if(parentObj.style.top=='') {parentObj.style.top=0;}\n"
                                   + "            parentObj.style.left = parseInt(parentObj.style.left) + window.event.clientX-oldX;\n"
                                   + "            parentObj.style.top  = parseInt(parentObj.style.top)  + window.event.clientY-oldY;\n"
                                   + "      }\n"
                                   + "}\n";
                  str += "function outDayTable() {\n"
                                   + "      document.writeln('<tr>');\n"
                                   + "      for (var i=0; i<myDays.length; i++) {\n"
                                   + "            if (i%7==0 && i>0) {document.writeln('</tr><tr>');}\n"
                                   + "            document.writeln(\"<td align=right id=dayTD\" + i + \" onclick=returnDate(\" + i + \") onmouseover=\\\"this.style.cursor='hand';this.style.color=setupColor;this.style.backgroundColor=setupBgColor;\\\" onmouseout='mouseOutDay(this, \" + i + \")'>\"+i+\"</td>\");\n"
                                   + "      }\n"
                                   + "      document.writeln('<td colspan=2 align=center onmouseover=this.style.cursor=\"hand\" onclick=parent.document."+this.name+".close()>关闭</td></tr>');\n"
                                   + "}\n";
                  str += "\/\/-->\n";
                  str += "<\/script>\n";
                  str += "<\/head>\n";

解决方案 »

  1.   

    str += "<body style='font-family:"+p.fontFamily+";margin: 0px;' oncontextmenu='return false' onselectstart='return false'>\n";
                      str += "<select name=yearSelect  id=yearSelect  onblur=\"this.style.display='none'\" onchange='yearChange(this);'  style='display:none;position:absolute;top:1;left:1;font-size:" + p.fontSize + "px;'>";
                      str += "<option value='2003'>2003年</option></select>\n";
                      str += "<select name=monthSelect id=monthSelect onblur=\"this.style.display='none'\" onchange='monthChange(this);' style='display:none;position:absolute;top:1;left:0;font-size:" + p.fontSize + "px;'>\n";
                      for (var i=1; i<=12; i++) {str += "<option value='"+i+"'>"+i+"月</option>";}
                      str += "</select>\n";
                      str += "<table id=calendarTable width='100%' border=0 cellspacing=0 cellpadding=0>";
                      str += "<tr><td id=headT0 width='100%' style='background-color:" + p.headBgColor + ";"
                                                      + "border-left:1px solid " + p.darkBorder + ";"
                                                      + "border-right:1px solid " + p.darkBorder + ";"
                                                      + "border-top:1px solid " + p.darkBorder + ";"
                                                      + "'>";
                      str += "<table id=headT1 width='100%' border=0 cellspacing=0 cellpadding=0 style='border:1px solid " + p.gridBorder + ";'>";
                      str += "<tr><td align=left>";
                      str += "<table id=headTD1 border=0 cellspacing=0 cellpadding=0 style='color:" + p.headColor + ";font-size:" + p.fontSize + "px;'><tr>";
                      str += "<td width=12 align=right onclick='previousYear()' title='向前翻1年'"
                                        + " style='font-family:Webdings;cursor: hand;'>3</td>";
                      str += "<td id=yearTD nowrap onclick='createYearSelect(parseInt(this.innerText, 10))'"
                                        + " onmouseover=this.style.cursor='hand' title='点击此处选择年份' style='padding-top:3px;'></td>";
                      str += "<td width=12 align=left  onclick='nextYear()'     title='向后翻1年'"
                                        + " style='font-family:Webdings;cursor: hand;'>4</td>";
                      str += "</tr></table></td><td align=right>";
                      str += "<table id=headTD2 border=0 cellspacing=0 cellpadding=0 style='color:" + p.headColor + ";font-size:" + p.fontSize + "px;'><tr>";
                      str += "<td width=12 aligh=right onclick='previousMonth()' title='向前翻1月'"
                                        + " style='font-family:Webdings;cursor: hand;'>3</td>";
                      str += "<td id=monthTD nowrap onclick='createMonthSelect(parseInt(this.innerText, 10))' title='点击此处选择月份'"
                                      + " onmouseover=\"this.style.cursor='hand'\" style='padding-top:3px;'>12月</td>";
                      str += "<td width=12 align=left  onclick='nextMonth()'     title='向后翻1月'"
                                      + " style='font-family:Webdings;cursor: hand;'>4</td>";
                      str += "</tr></table></td></tr></table></td></tr>";
                      str += "<tr><td style='border-top:1px solid #FFFFFF;border-bottom:1px solid #FFFFFF'>\n";
                      str += "<table id=weekT0 border=0 width=100% cellpadding=2 cellspacing=1"
                            + " style='background-color:" + p.gridBorder + ";font-size:" + p.fontSize + "px;"
                            + "border-left:1px solid " + p.darkBorder + ";border-right:1px solid " + p.darkBorder + ";'>\n";
                      str += "<tr id=weekT1 align=center style='background-color:" + p.weekBgColor + ";color:" + p.weekColor + ";'"
                            + " title='按住此处可拖动窗口' onmouseover=\"if (allowMove) {this.style.cursor='move'; this.title='按住此处可拖动窗口';} else {this.style.cursor='default'; this.title='';}\""
                            + " onmousedown='dragBegin(this)' onmouseup='dragEnd(this)'>\n";
                      str += "<td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>\n";
                      str += "</table></td></tr><tr><td valign=top>";
                      str += "<table id=dayTable width=100% border=0 cellspacing=1 cellpadding=4"
                                 + " style='background-color:" + p.gridBorder + ";border-right:1px solid " + p.darkBorder
                                 + ";border-left:1px solid " + p.darkBorder+";font-size:" + p.fontSize + "px;'>";
                      str += "<s"+"cript>outDayTable();<\/script>";
                      str += "</table></td></tr><tr><td height=1 bgcolor=#FFFFFF></td></tr><tr><td height=2 bgcolor=#E0DFE5></td></tr>";
                      str += "<tr><td id=lastLine height=1 style='background-color:" + p.darkBorder + ";'></td></tr><table>";
                      str += "<\/body>";
                      str += "<\/html>\n";                  with (window.frames[objID + "_frame"].document) {
                            open("text/html");
                            writeln(str);
                            close();
                      }
      

  2.   

    //---------------- 定义要用到的变量和对象 ------------------                  var newObj = eval(objName2);                            // 日历控件的层
                      newObj.parameter   = p;                                 // 日历的参数集
                      newObj.eventSrc    = null;                              // 获取日历的触发控件
                      newObj.frame       = eval(objName2 + "_frame");         // 日历控件的 iframe 载体元素
                      newObj.frameWindow = window.frames[objID + "_frame"];   // 日历控件的 iframe 载体窗口//--------------- 载入一批函数 ----------------------------                  newObj.reset = function(p) {             // 重置日历
                            this.open();
                            if (p != null) {this.parameter = p;}
                            this.frameWindow.yearOffset    = this.parameter.yearOffset;
                            this.frameWindow.minYear       = this.parameter.minYear;
                            this.frameWindow.maxYear       = this.parameter.maxYear;
                            this.frameWindow.seperator     = this.parameter.seperator;
                            this.frameWindow.dateFormater  = this.parameter.dateFormater;
                            this.frameWindow.wordColor     = this.parameter.wordColor;
                            this.frameWindow.wordDark      = this.parameter.wordDark;
                            this.frameWindow.dayBgColor    = this.parameter.dayBgColor;
                            this.frameWindow.todayBgColor  = this.parameter.todayBgColor;
                            this.frameWindow.oldDayBgColor = this.parameter.oldDayBgColor;
                            this.frameWindow.allowMove     = this.parameter.allowMove;
                            this.frameWindow.setupBgColor  = this.parameter.setupBgColor;
                            this.frameWindow.setupColor    = this.parameter.setupColor;
                            this.frameWindow.document.body.style.fontFamily              = this.parameter.fontFamily;
                            this.frameWindow.yearSelect.style.fontSize                   = this.parameter.fontSize + "px";
                            this.frameWindow.monthSelect.style.fontSize                  = this.parameter.fontSize + "px";
                            this.frameWindow.document.all.headT0.style.backgroundColor   = this.parameter.headBgColor;
                            this.frameWindow.document.all.headT1.style.backgroundColor   = this.parameter.headBgColor;
                            this.frameWindow.document.all.headT1.style.fontSize          = this.parameter.fontSize + "px";
                            this.frameWindow.document.all.headTD1.style.color            = this.parameter.headColor;
                            this.frameWindow.document.all.headTD1.style.fontSize         = this.parameter.fontSize + "px";
                            this.frameWindow.document.all.headTD2.style.color            = this.parameter.headColor;
                            this.frameWindow.document.all.headTD2.style.fontSize         = this.parameter.fontSize + "px";
                            this.frameWindow.document.all.weekT0.style.backgroundColor   = this.parameter.gridBorder;
                            this.frameWindow.document.all.weekT0.style.fontSize          = this.parameter.fontSize + "px";
                            this.frameWindow.document.all.weekT1.style.backgroundColor   = this.parameter.weekBgColor;
                            this.frameWindow.document.all.weekT1.style.color             = this.parameter.weekColor;
                            this.frameWindow.document.all.dayTable.style.backgroundColor = this.parameter.gridBorder;
                            this.frameWindow.document.all.dayTable.style.fontFamily      = this.parameter.fontFamily;
                            this.frameWindow.document.all.dayTable.style.fontSize        = this.parameter.fontSize + "px";
                            this.frameWindow.document.all.lastLine.style.backgroundColor = this.parameter.darkBorder;
                            this.frameWindow.resetDays();
                            var w = parseInt(this.frameWindow.document.all.calendarTable.offsetWidth, 10);
                            var h = parseInt(this.frameWindow.document.body.scrollHeight, 10);
                            this.style.width  = w;
                            this.style.height = h;
                            this.frame.style.width  = w;
                            this.frame.style.height = h;
                      }
                      newObj.open = function(d) {                              // 显示日历。d:输入日期值
                            this.eventSrc = window.event.srcElement;
                            if (d == null) {d = this.eventSrc.value;}
                            var e = this.eventSrc;
                            var t = e.offsetTop, h = e.clientHeight, l = e.offsetLeft;
                            while (e = e.offsetParent) {t += e.offsetTop; l += e.offsetLeft;}
                            var cw = this.clientWidth, ch = this.clientHeight;
                            var dw = document.body.clientWidth, dl = document.body.scrollLeft, dt = document.body.scrollTop;
                            if (document.body.clientHeight + dt - t - h >= ch) {this.style.top = (t+h+6);}
                            else {this.style.top  = (t - dt < ch) ? (t+h+6) : (t-ch);}
                            if (dw + dl - l >= cw) {this.style.left = l;}
                            else {this.style.left = (dw >= cw) ? (dw-cw+dl) : dl;}
                            this.style.display = "block";
                            var w = parseInt(this.frameWindow.document.all.calendarTable.offsetWidth, 10);
                            var h = parseInt(this.frameWindow.document.body.scrollHeight, 10);
                            this.style.width  = w;
                            this.style.height = h;
                            this.frame.style.width  = w;
                            this.frame.style.height = h;
    //                        this.frameWindow.width = w;
    //                        this.frameWindow.height = h;
                            this.frameWindow.inputDate = d;
                            var yy = new Date().getYear();
                            var mm = (new Date().getMonth()+1);
                            if (d!=null && d!="") {
                                  var ss = d.split(this.parameter.seperator);
                                  if (ss.length > 0) {yy = parseInt(ss[0], 10);}
                                  if (ss.length > 1) {mm = parseInt(ss[1], 10);}
                            }
                            if (isNaN(yy)) {this.frameWindow.currentYear = new Date().getYear();}
                            else {this.frameWindow.currentYear = yy;}
                            if (isNaN(mm)) {this.frameWindow.currentMonth = (new Date().getMonth()+1);}
                            else {this.frameWindow.currentMonth = mm;}
                            this.frameWindow.resetDays();
                            this.frameWindow.focus();
                      }
                      newObj.close = new Function("this.style.display = 'none';");                     // 隐藏日历                  this.webCalendar = newObj;
                }
    //--------------------
                return this;
          }
          var tt = new this.create(name);
          if (tt != null) {eval("document." + name + " = tt");}
          return tt;
    }//-->
      

  3.   

    http://expert.csdn.net/Expert/topic/2680/2680267.xml?temp=.7875635
    前一页在这,真不错