document.all在Firefox中不起作用 [英] document.all is not working in Firefox

查看:119
本文介绍了document.all在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个旧的维护项目。我发现 document.all 在Firefox 25中不起作用。我得到下面的错误信息。



<$ p $ > TypeError:document.all.TabularDataControlAttivitta.object is undefined

示例代码是:

  document.all.TabularDataControlProj.object.Filter ='COMPANYCODE ='+ compValue; 
document.all.TabularDataControlProj.object.Reset();
document.getElementById('cmbActivity_'+ rowNo).options.length = 1;
if(document.getElementById('cmbProject_'+ rowNo).options.length> 0){
for(var i = document.getElementById('cmbProject_'+ rowNo).options.length - 1 ; i> = 0; i--){
document.getElementById('cmbProject _'+ rowNo).options [i] = null;


if(document.all.TabularDataControlProj.recordset.recordcount> 0){
document.all.TabularDataControlProj.recordset.movefirst;
}
pOption = new Option(' - Select-',-1);
document.getElementById('cmbProject_'+ rowNo).add(pOption); $(document.all.TabularDataControlProj.recordset.fields(0)+' - '+ document.all .TabularDataControlProj.recordset.fields(2)),document.all.TabularDataControlProj.recordset.fields(0));
document.getElementById('cmbProject_'+ rowNo).add(Optionp);
document.getElementById('cmbProject_'+ rowNo).selectedIndex = indxAct;
document.all.TabularDataControlProj.recordset.movenext;




$ b $ p $任何补丁或解决方案?因为编辑整个项目非常困难。

解决方案

document.all 是非标准的。这是他们添加到IE的一个微软特有的功能。大多数其他浏览器从来没有支持它。



即使在IE中,它现在已经被弃用了。你不应该使用它。



(您的旧项目必须非常旧,因为现在已经有相当一段时间了)

对于大多数情况,您可以使用 document.getElementById()。如果使用 document.all 来获取使用ID值的元素,那么 document.getElementById()是一个直接替换。



如果您使用 document.all 以某种方式获取元素,那么我建议切换到通过ID获得它(如果需要,添加一个ID)。

我注意到你使用元素的方式看起来像它可能是一个ActiveX控件? (即我看到像 .object.Filter .recordset.movefirst 等等)



如果是这种情况,那么您需要知道Firefox根本不支持activeX控件。他们也是特定于IE。如果它是一个ActiveX控件,并且你需要它在Firefox中工作,那么不幸的是,你可能在你之前有很多重写。


I am working on an old project for maintenance. I found that document.all is not working in Firefox 25. And I am getting the error below.

TypeError: document.all.TabularDataControlAttivitta.object is undefined

And my sample code is:

document.all.TabularDataControlProj.object.Filter = 'COMPANYCODE=' + compValue;
document.all.TabularDataControlProj.object.Reset();
document.getElementById('cmbActivity_' + rowNo).options.length = 1;
if (document.getElementById('cmbProject_' + rowNo).options.length > 0) {
    for (var i = document.getElementById('cmbProject_' + rowNo).options.length - 1; i >= 0; i--) {
        document.getElementById('cmbProject_'+rowNo).options[i] = null;
    }
}
if (document.all.TabularDataControlProj.recordset.recordcount > 0) {
    document.all.TabularDataControlProj.recordset.movefirst;
}
pOption = new Option('-Select-', -1);
document.getElementById('cmbProject_' + rowNo).add(pOption);
while (document.all.TabularDataControlProj.recordset.eof == false) {
    Optionp = new Option((document.all.TabularDataControlProj.recordset.fields(0) + ' - ' + document.all.TabularDataControlProj.recordset.fields(2)), document.all.TabularDataControlProj.recordset.fields(0));
    document.getElementById('cmbProject_' + rowNo).add(Optionp);
    document.getElementById('cmbProject_' + rowNo).selectedIndex = indxAct;
    document.all.TabularDataControlProj.recordset.movenext;
    }
}

Any patch or solution for this? Because it's very difficult to edit the entire project.

解决方案

document.all is non-standard. It was a Microsoft-specific feature that they added to IE. Most other browsers have never supported it.

Even in IE it is now deprecated. You should not be using it.

(your old project must be very old, because this has been the case for quite some time now)

For most cases, you can use document.getElementById() instead.

If you're using document.all to get an element using it's ID value then document.getElementById() is a direct replacement.

If you're using document.all to get an element some other way, then I recommend switching to getting it by ID (add an ID if necessary).

I note that the way you're using the element makes it look like it may be an activeX control? (ie I see stuff like .object.Filter, .recordset.movefirst, etc)

If that is the case, then you need to be aware that Firefox does not support activeX controls at all. They are also specific to IE. If it is an activeX control and you need it to work in Firefox then unfortunately, you probably have quite a lot of rewriting ahead of you.

这篇关于document.all在Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆