Document.all does not work in Firefox

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

 TypeError: document.all.TabularDataControlAttivitta.object is undefined 

And my code example:

 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 is very difficult to edit the entire project.

0
source share
3 answers

document.all is non-standard. This 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 use it.

(your old project should be very old, because this has been happening for quite some time)

In most cases, you can use document.getElementById() .

If you use document.all to get an element using its identifier, then document.getElementById() is a direct replacement.

If you use document.all to get an element in some other way, I recommend switching to receiving it by ID (add an identifier if necessary).

I note that the way the element is used makes it look like an activeX control. (i.e. I see things like .object.Filter , .recordset.movefirst , etc.)

If so, then you need to know that Firefox does not support ActiveX controls at all. They are also specific to IE. If this is an activeX control, and you need it to work in Firefox, then, unfortunately, you probably have quite a few rewriting you.

+3
source

Document.all Provides access to all elements with an identifier. This is an outdated non-standard interface, you should use the document.getElementById() method.

Link: https://developer.mozilla.org/en/docs/Web/API/Document

+1
source

As the error says, the problem is not that document.all does not work (it does), but with document.all.TabularDataControlAttivitta.object is undefined. This may be due either to specific applications (you simply do not define an object expando), or because you have multiple elements with a name or identifier equal to TabularDataControlAttivitta.

+1
source

Source: https://habr.com/ru/post/1012390/


All Articles