Closed Bug 209453 Opened 22 years ago Closed 22 years ago

document.forms.length=0 if the script is before a FORM

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: dcl441-bugs, Assigned: rogerl)

References

()

Details

Attachments

(1 file)

Mozilla Firebird 2003061308 There are some pages (see URL) that fail to count the number of forms because the JavaScript is in the HEAD tag, obviously before any FORM tag. I attach a simpler testcase.
Attached file testcase
This seems like the proper behaviour: if the page hasn't finished loading then Mozilla can't guess how many forms will be in the page, it only knows how many forms have been created so far. IE 5.5 shows the same behaviour. Does this example work like you want it to do in any browser at all?
This is invalid. The behavior here is the same in all browsers -- the script executes when the <script> tag is processed, which is before anything else has been parsed (this is the only way document.write() can work reasonably). If you need to make sure the script only runs when the DOM is complete, run it off the onload event.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Marking Verified -
Status: RESOLVED → VERIFIED
OK. The URL doesn't work due to this, I suppose it's webmaster's fault then. (see bug 113140 comment 6)
Yes. Which is why the bug is Tech Evang....
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: