0

我已经在网上浏览了很多答案和其他地方,但我没有发现任何人以与我相同的方式遇到错误。

我的浏览器刚刚更新到 IE10,这引起了我们的注意。如果我在兼容模式下运行,该功能似乎工作得很好。如果我不在兼容模式下,我会收到 IE 调试器错误 SCRIPT5002 - Function Expected 错误。

我已经用 ==> 标记了出现错误的地方。如果我取出该变量并用 document.frames... 替换该变量,那么它将将该行引用为问题。任何帮助,将不胜感激。

我从以前的员工那里继承了这段代码,并且只使用 javascript 大约 3 个月。这是代码:

function FncSaveClient(){
//Submit Primary Client form
//Verify Data
==> var CntSumFrm = document.frames('IFrameSummary').document.all.item('DefaultFrm');
if (CntSumFrm.fireEvent('onsubmit') == true){
    CntSumFrm.submit();
}
//If Edit Mode Submit Subforms
var IntAcctNum = CntSumFrm.TxtAcctNum.value
if (IntAcctNum != 0){
    //Locations Subform
    var CntLocFrm = document.frames('IFrameLocations').document.all.item('DefaultFrm');
    if (CntLocFrm.fireEvent('onsubmit') == true){
          CntLocFrm.submit();
      }
    //Contacts Subform
    var CntContactTbl = document.frames('IFrameContacts').document.all.item('TblContactSummary')
if (CntContactTbl.rows.length-3 == 0){
        alert('You must have at least one contact per client.');
    document.all.item('BtnSubTblClientContacts').style.color='red';
    }
    //Classification Subform
    var CntClassFrm = document.frames('IFrameMarketing').document.frames('IFrameClassification').document.all.item('DefaultFrm');
    if (CntClassFrm.fireEvent('onsubmit') == true){
        CntClassFrm.submit();
      }
    //Save Client Admin
    var CntAdminFrm = document.frames('IFrameAdmin').document.all.item('DefaultFrm');
    if (CntAdminFrm.fireEvent('onsubmit') == true){
    CntAdminFrm.submit();
}
else
{
    document.all.item('BtnSubTblSalesRel').style.color='red';
}   
}

if(CntSumFrm.TxtDeleted.value == 1)
    {
    window.parent.location.href = '/Accounts/';
    }
}
4

2 回答 2

1

That code is full of ancient IE-specific code, that is probably not allowed anymore even by IE, unless in compatibility mode. You should look into replacing stuff like:

  • document.frames
  • document.all
  • .items()

I believe the error happens because frames or item (maybe both) is not a function when IE follows the JS standards.

于 2013-04-04T14:29:47.060 回答
0

我今天在 2005 年写的 Java Script 也有类似的问题。使用 IE10 的外部用户(我们仍使用 IE8)无法正常工作。看来 document.all 已被弃用,只能在兼容模式下访问。我删除了对 IE 的检查,因此它现在使用我已经为其他浏览器使用的 document.getElementById,即使关闭了兼容模式,它似乎也可以工作。

于 2013-04-04T16:38:00.457 回答