Closed Bug 452581 Opened 16 years ago Closed 16 years ago

document.all is no longer recognized

Categories

(Core :: DOM: Core & HTML, enhancement)

1.9.0 Branch
x86
Windows XP
enhancement
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 74201

People

(Reporter: engxladso, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 The following client-side javascript function crashes. Worked in previous release of Firefox. Works in IE. function ToggleEdit(URL,BtnClicked) { var elements = window.document.all; for(var i=0; i<elements.length;i++){ var ControlId = elements[i].id; if(ControlId.indexOf("BtnClicked") != -1) { document.getElementById(ControlId).value = BtnClicked.id; } } document.forms[0].action = URL; document.forms[0].submit(); return false; } the error console says "elements is undefined" and points to the line containing: for(var i=0; i<elements.length;i++){ Reproducible: Always Steps to Reproduce: 1.Click following html element: <a onclick="ToggleEdit('Editservices.aspx',this);" id="EditBtn1" title="Edit the contents of this page" class="BibVNavBtn" href="javascript:__doPostBack('EditBtn1','')" style="position:absolute;top:5px;left:10px;">EDIT</a> This element looks a bit weird because it is asp.net generated. Actual Results: original page redisplayed Expected Results: form submitted with new page (Editservices.aspx) displayed. Should not crash in javascript functions that previously worked
Further research reveals that Firefox 3.0.1 doesn't recognize the following javascript: 'window.document.all' since when I included the following alert at the top of this function: alert(window.document.all); the popup alert contained the text: undefined
I have found a way around this. I have replaced var elements = window.document.all; with var elements = document.getElementsByTagName("*"); In my opinion document.all is a more elegent statement for obtaining an array of page elements than document.getElementsByTagName("*") but what do I know. I'm just a lowly developer and the standards nazis have deemed differently.
http://developer.mozilla.org/en/Mozilla_Web_Developer_FAQ#JavaScript_doesn.e2.80.99t_work!_Why.3f it is highly unlikely that we would add support for this quirk. your content is broken and you should fix it since you have a pulse.
Severity: critical → enhancement
Component: General → DOM: Core & HTML
Product: Firefox → Core
QA Contact: general → general
Summary: a javascript function no longer works since installing firefox 3.0.1 → document.all isn't treated as an array for length checking (compat with lame sites)
Version: unspecified → 1.9.0 Branch
(In reply to comment #3) > http://developer.mozilla.org/en/Mozilla_Web_Developer_FAQ#JavaScript_doesn.e2.80.99t_work!_Why.3f > > it is highly unlikely that we would add support for this quirk. your content is > broken and you should fix it since you have a pulse. timeless, I am not surprised by your arrogant, rude, cowardly response; and I call you cowardly because you wouldn't dare be this rude to my face. In Comment #2 above I have already stated that I have worked around this error. And if you are not going to bother to fix this bug which wasn't present in previous versions of Firefox, then that typifies an attitude that will lead Firefox to go the same way as Netscape. I have to say I am finding the new release of Firefox slow compared to IE, and I am not talking about my sites here, but with other sites, such as that for Britain's biggest web hosting company. And one more thing, before you try to blame the victim in future like you have to me, realize that this writer of 'lame' websites has been doing software development for 18 years, so show some respect!
Summary: document.all isn't treated as an array for length checking (compat with lame sites) → document.all is no longer recognized
Adam - document.all hasn't been supported in Mozilla since I started working on this project, and I've been a software developer (specializing in Mozilla code) for at least seven years. I literally wrote a book on JavaScript, including the HTML DOM. I've literally been working with computers all my life. I'll try to be more respectful than some of my colleagues. The decision to not support document.all literally goes all the way back to Netscape 6 days, when - as the article timeless refers to - websites were using object detection to determine what browser they're running on. It was specifically this sort of problem that caused the need for W3C DOM standards in the first place. Unfortunately, many websites still rely on document.all and its "friends" for browser detection. The minute we start supporting this, we break them. Incidentally, this issue has come up repeatedly in the past. We have eight duplicate bugs on file about document.all. I am marking this one the ninth. With no sarcasm intended, I am wishing you have a nice day. :)
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.