关于win7下IE9运行JS出错的问题
写了个选日期控件
<!--/* 引用方法: <script language="javascript" src="../01_Common/nls-Calendar.js"></script>*//* 调用方法: <input onfocus="calendar()" name="txt1" type="text" id="txt1" />*/var cal_Width = 180;//定义日历显示的宽度,至少140document.write("<div id='meizzCalendarLayer' style='position: absolute; z-index: 9999; width: " + (cal_Width+4).toString() + "px; height: 193px; display: none'>");document.write("<iframe name='meizzCalendarIframe' scrolling='no' frameborder='0' width='100%' height='100%'></iframe></div>");var WebCalendar = new WebCalendar();function document.onclick(){ if(WebCalendar.eventSrc != window.event.srcElement) hiddenCalendar();}function WebCalendar() //初始化日历的设置{ //显示不下就不发了。。} function writeIframe(){ //显示不下就不发了。。}function calendar() //主调函数{ var e = window.event.srcElement; writeIframe(); var o = WebCalendar.calendar.style; WebCalendar.eventSrc = e; if (arguments.length == 0) WebCalendar.objExport = e; else WebCalendar.objExport = eval(arguments[0]); WebCalendar.iframe.tableWeek.style.cursor = WebCalendar.drag ? "move" : "default"; var t = e.offsetTop, h = e.clientHeight, l = e.offsetLeft, p = e.type; while (e = e.offsetParent){t += e.offsetTop; l += e.offsetLeft;} o.display = ""; WebCalendar.iframe.document.body.focus(); var cw = WebCalendar.calendar.clientWidth, ch = WebCalendar.calendar.clientHeight; var dw = document.body.clientWidth, dl = document.body.scrollLeft, dt = document.body.scrollTop; if (document.body.clientHeight + dt - t - h >= ch) o.top = (p=="image")? t + h : t + h + 6; else o.top = (t - dt < ch) ? ((p=="image")? t + h : t + h + 6) : t - ch; if (dw + dl - l >= cw) o.left = l; else o.left = (dw >= cw) ? dw - cw + dl : dl; if (!WebCalendar.timeShow) WebCalendar.dateReg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/; else WebCalendar.dateReg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; try{ if (WebCalendar.objExport.value.trim() != ""){ WebCalendar.dateStyle = WebCalendar.objExport.value.trim().match(WebCalendar.dateReg); if (WebCalendar.dateStyle == null) { WebCalendar.thisYear = new Date().getFullYear(); WebCalendar.thisMonth = new Date().getMonth()+ 1; WebCalendar.thisDay = new Date().getDate(); alert("原文本框里的日期有错误!\n可能与你定义的显示时分秒有冲突!"); writeCalendar(); return false; } else { WebCalendar.thisYear = parseInt(WebCalendar.dateStyle[1], 10); WebCalendar.thisMonth = parseInt(WebCalendar.dateStyle[3], 10); WebCalendar.thisDay = parseInt(WebCalendar.dateStyle[4], 10); WebCalendar.inputDate = parseInt(WebCalendar.thisDay, 10) +"/"+ parseInt(WebCalendar.thisMonth, 10) +"/"+ parseInt(WebCalendar.thisYear, 10); writeCalendar(); } } else { WebCalendar.thisYear = new Date().getFullYear(); WebCalendar.thisMonth = new Date().getMonth()+ 1; WebCalendar.thisDay = new Date().getDate(); writeCalendar(); } } catch(e) { WebCalendar.thisYear = new Date().getFullYear(); WebCalendar.thisMonth = new Date().getMonth()+ 1; WebCalendar.thisDay = new Date().getDate(); writeCalendar(); }}function funMonthSelect() //月份的下拉框{ //显示不下就不发了。。}function funYearSelect() //年份的下拉框{ //显示不下就不发了。。}function prevM() //往前翻月份{ //显示不下就不发了。。}function nextM() //往后翻月份{ //显示不下就不发了。。}function prevY(){WebCalendar.thisDay = 1; WebCalendar.thisYear--; writeCalendar();}//往前翻 Yearfunction nextY(){WebCalendar.thisDay = 1; WebCalendar.thisYear++; writeCalendar();}//往后翻 Yearfunction hiddenSelect(e){ //for(var i=e.options.length; i>-1; i--)e.options.remove(i); e.style.display="none";}function getObjectById(id){ if(document.all) return(eval("document.all."+ id)); return(eval(id)); }function hiddenCalendar(){getObjectById("meizzCalendarLayer").style.display = "none";};function appendZero(n){return(("00"+ n).substr(("00"+ n).length-2));}//日期自动补零程序function String.prototype.trim(){return this.replace(/(^\s*)|(\s*$)/g,"");}function dayMouseOver(){ //....}function dayMouseOut(){ //....}function writeCalendar() //对日历显示的数据的处理程序{ //显示不下就不发了。。}function returnDate() //根据日期格式等返回用户选定的日期{ //显示不下就不发了。。}//-->
<head><script language="javascript" src="../01_Common/nls-Calendar.js"></script></head><td class="lst01" align="left" style="width: 666px"> <input name="txtStartDate" type="text" id="txtStartDate" onclick="calendar();" /></td>