dhtmlgoodies calendar.js不适用于Firefox和Chrome - c#

我在asp.net应用程序中有一个dhtmlgoodies_calendar,并且对writeCalendarContent方法进行了一些更改以禁用过去的日期。它在Internet Explorer上运行良好。但是在Firefox和Chrome中,过去的日期仍然会显示。

是否有人对如何在这些浏览器中进行这项工作有任何想法?
任何帮助表示赞赏。
谢谢

这是我的方法:

       function writeCalendarContent()
{
    var blockDateInPast = true;
    var calendarContentDivExists = true;
    if(!calendarContentDiv){
        calendarContentDiv = document.createElement('DIV');
        calendarDiv.appendChild(calendarContentDiv);
        calendarContentDivExists = false;
    }
    currentMonth = currentMonth/1;
    var d = new Date();

    var data = new Date();

    var AnoAtual = data.getYear();
    var MesAtual = data.getMonth();
    var DiaAtual = data.getDate();

    d.setFullYear(currentYear);
    d.setDate(1);
    d.setMonth(currentMonth);

    var dayStartOfMonth = d.getDay();
    if (! weekStartsOnSunday) {
      if(dayStartOfMonth==0)dayStartOfMonth=7;
      dayStartOfMonth--;
   }

    document.getElementById('calendar_year_txt').innerHTML = currentYear;
    document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth];
    document.getElementById('calendar_hour_txt').innerHTML = currentHour;
    document.getElementById('calendar_minute_txt').innerHTML = currentMinute;

    var existingTable = calendarContentDiv.getElementsByTagName('TABLE');
    if(existingTable.length>0){
        calendarContentDiv.removeChild(existingTable[0]);
    }

    var calTable = document.createElement('TABLE');
    calTable.width = '100%';
    calTable.cellSpacing = '0';
    calendarContentDiv.appendChild(calTable);




    var calTBody = document.createElement('TBODY');
    calTable.appendChild(calTBody);
    var row = calTBody.insertRow(-1);
    row.className = 'calendar_week_row';
   if (showWeekNumber) {
      var cell = row.insertCell(-1);
       cell.innerHTML = weekString;
       cell.className = 'calendar_week_column';
       cell.style.backgroundColor = selectBoxRolloverBgColor;
    }

    for(var no=0;no<dayArray.length;no++){
        var cell = row.insertCell(-1);
        cell.innerHTML = dayArray[no];
    }

    var row = calTBody.insertRow(-1);

   if (showWeekNumber) {
       var cell = row.insertCell(-1);
       cell.className = 'calendar_week_column';
       cell.style.backgroundColor = selectBoxRolloverBgColor;
       var week = getWeek(currentYear,currentMonth,1);
       cell.innerHTML = week;       // Week
    }
    for(var no=0;no<dayStartOfMonth;no++){
        var cell = row.insertCell(-1);
        cell.innerHTML = '&nbsp;';
    }

    var colCounter = dayStartOfMonth;
    var daysInMonth = daysInMonthArray[currentMonth];
    if(daysInMonth==28){
        if(isLeapYear(currentYear))daysInMonth=29;
    }

    for(var no=1;no<=daysInMonth;no++){
        d.setDate(no-1);
        if(colCounter>0 && colCounter%7==0){
            var row = calTBody.insertRow(-1);
         if (showWeekNumber) {
            var cell = row.insertCell(-1);
            cell.className = 'calendar_week_column';
            var week = getWeek(currentYear,currentMonth,no);
            cell.innerHTML = week;      // Week
            cell.style.backgroundColor = selectBoxRolloverBgColor;
         }
        }
        var cell = row.insertCell(-1);


            if (currentYear<AnoAtual && blockDateInPast==true)
            {
               cell.className='DesactiveDay';
               cell.onclick = null;

            }
            else if (currentYear==AnoAtual)
            {
                if (currentMonth < MesAtual && blockDateInPast == true)
                {
                 cell.className='DesactiveDay';
                  cell.onclick = null;
                }
                else if (currentMonth==MesAtual)
                {
                    if (no < DiaAtual && blockDateInPast == true)
                    {
                     cell.className='DesactiveDay';
                      cell.onclick = null;
                     }
                     else
                     {
                     cell.onclick = pickDate;

                     }

                }
                else
                {
                 cell.onclick = pickDate;
                }

            }
            else
            {
            cell.onclick = pickDate;
            }

        if (cell.onclick == pickDate)
        {
        if(currentYear==inputYear && currentMonth == inputMonth && no==inputDay){
            cell.className='activeDay';
            cell.onclick = pickDate;
        }
        }
        cell.innerHTML = no;

        colCounter++;
    }


    if(!document.all){
        if(calendarContentDiv.offsetHeight)
            document.getElementById('topBar').style.top = calendarContentDiv.offsetHeight + document.getElementById('timeBar').offsetHeight + document.getElementById('topBar').offsetHeight -1 + 'px';
        else{
            document.getElementById('topBar').style.top = '';
            document.getElementById('topBar').style.bottom = '0px';
        }

    }

    if(iframeObj){
        if(!calendarContentDivExists)setTimeout('resizeIframe()',350);else setTimeout('resizeIframe()',10);
    }




}

参考方案

只需在writeCalendarContent()的末尾添加以下代码,

 if(currentYear==inputYear && currentMonth == inputMonth && no==inputDay){
    cell.className='activeDay';
    cell.onclick = pickDate;
 }
 else if(currentYear<inputYear || currentMonth < inputMonth || no<inputDay){
    cell.className = 'inactive-date';
 }
 else{
    cell.onclick = pickDate;
 }
 cell.innerHTML = no;
 colCounter++;

它仅针对当前日期和下一个日期添加单击事件。它不会为过去的日期添加点击。您可以为过去的日期添加样式(为非活动日期类添加样式)。

将字符串分配给numpy.zeros数组[重复] - python

This question already has answers here: Weird behaviour initializing a numpy array of string data                                                                    (4个答案)         …

如何修复AttributeError:模块'numpy'没有属性'square' - python

Improve this question 我已经将numpy更新为1.14.0。我使用Windows10。我尝试运行我的代码,但出现此错误: AttributeError:模块“ numpy”没有属性“ square”这是我的进口商品:%matplotlib inline import matplotlib.pyplot as plt import ten…

AttributeError:'AnonymousUserMixin'对象没有属性'can' - python

烧瓶学习问题为了定制对匿名用户的要求,我在模型中设置了一个类: class MyAnonymousUser(AnonymousUserMixin): def can(self, permissions): return False def is_administrator(self): return False login_manager.anonymous…

如何在python中连接熊猫数据框 - python

我有一个python对象列表,有些像这样team_1_players1=[] is a list 在team_1_players1 = []内部,存储了多个json对象。1st Json Object像这样[[{'age_days': '72', 'age_years': '30'…

无法将类型'System.ValueType'隐式转换为'int?' - c#

我有一个C ++ / CLI包装器类,可在C#和本机C ++之间互操作。我收到与System.Nullable相关的奇怪错误。我了解,对于基本类型,System.Nullable<T>等效于T?。所以我这样做:C#:public int? RoboticsArmRotation { get { return mRobotics.ArmRotati…