function ShowCalendar(InputBox)    //页面onclick调用此方法,参数是调用此方法的输入框的id
{
    var x,y,intLoop,intWeeks,intDays;
    var DivContent;
    var year,month,day;
    var o=eval("document.all."+InputBox);     //就是这了,firefox执行到这就报undefine错误,请问该如何改
    var thisyear; 
    
    thisyear=new getToday();
    thisyear=thisyear.year;
    
    today = o.value;
    if(isDate(today))
        today = new getStringDay(today);
    else
        today = new getToday(); 
        x=o.offsetLeft;
    y=o.offsetTop;
    while(o=o.offsetParent)
    {
        x+=o.offsetLeft;
        y+=o.offsetTop;
    }
    document.all.CalendarIframe.style.left=x+2;
    document.all.CalendarIframe.style.top=y+20;
    document.all.CalendarIframe.style.visibility="visible";
    document.all.Calendar.style.left=x+2;
    document.all.Calendar.style.top=y+20;
    document.all.Calendar.style.visibility="visible";
    
    //下面开始输出日历表格(border-color:#9DBAF7)
    DivContent="<table border='0' cellspacing='0' style='width:153px;border:1px solid #0066FF; background-color:#EDF2FC'>";
    DivContent+="<tr height='20px'>";
    DivContent+="<td style='border-bottom:1px solid #0066FF; background-color:#C7D8FA'>";
    
    //年
    DivContent+="<select name='Year' id='Year' onChange='newCalendar()' style='font-family:Verdana; font-size:12px'>";
    for (intLoop = thisyear - 100; intLoop < (thisyear + 100); intLoop++) 
        DivContent+="<option value= " + intLoop + " " + (today.year == intLoop ? "Selected" : "") + ">" + intLoop + "</option>"; 
    DivContent+="</select>";
    
    //月
    DivContent+="<select name='Month' id='Month' onChange='newCalendar()' style='font-family:Verdana; font-size:12px'>";
    for (intLoop = 0; intLoop < months.length; intLoop++) 
        DivContent+="<option value= " + (intLoop + 1) + " " + (today.month == intLoop ? "Selected" : "") + ">" + months[intLoop] + "</option>"; 
    DivContent+="</select>";
    
    DivContent+="</td>";
    
    DivContent+="<td style='border-bottom:1px solid #0066FF; background-color:#C7D8FA; font-weight:bold; font-family:Wingdings 2,Wingdings,Webdings; font-size:16px; padding-top:2px; color:#4477FF; cursor:hand' align='center' title='关闭' onClick='javascript:HiddenCalendar()'>S</td>";
    DivContent+="</tr>";
     
    DivContent+="<tr><td align='center' colspan='2'>";
    DivContent+="<table id='calendar' border='0' width='100%' height='140px'>";
    
    //星期
    DivContent+="<tr height='20px'>";
    for (intLoop = 0; intLoop < days.length; intLoop++) 
        DivContent+="<td align='center' style='font-size:12px'>" + days[intLoop] + "</td>"; 
    DivContent+="</tr>";
    
    //天
    for (intWeeks = 0; intWeeks < 6; intWeeks++)
    { 
        DivContent+="<tr>"; 
        for (intDays = 0; intDays < days.length; intDays++) 
            DivContent+="<td onClick='GetDate(\"" + InputBox + "\")' style='cursor:hand; border-right:1px solid #BBBBBB; border-bottom:1px solid #BBBBBB; color:#215DC6; font-family:Verdana; font-size:12px' align='center'></td>"; 
        DivContent+="</tr>"; 
    } 
    DivContent+="</table></td></tr>";
    DivContent+="<tr><td align='center'><input type='button' onclick='javascript:clearInput(\""+InputBox+"\");' value=' 清除 '/></td></tr>";
    DivContent+="</table>";    document.all.Calendar.innerHTML=DivContent;
    newCalendar();
}

解决方案 »

  1.   

     var o=eval("document.all."+InputBox); var o = function() {
       return document.all[InputBox];
    }();你看下行不行,如果不行的话document.all这个方法就要换了
      

  2.   

    ocument.name.XXX
    document.getELementById(id)
    document.getELementsByName(name)
      

  3.   

    统一使用document.getElementById
    eval在ie下也很耗性能。
    eval is evil
      

  4.   

    换成了document.getElementById,是能弹出控件来了,但是弹出控件的位置不在鼠标的位置,而且面板上也没日期显示,哎,伤脑筋,里面用到的层太多了,用了好多不标准的dom属性和方法,