Closed Bug 402537 Opened 17 years ago Closed 17 years ago

HTML parser ships <script> to implicit <head>, breaking getElementById in inline script

Categories

(Core :: DOM: HTML Parser, defect)

defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 178258

People

(Reporter: buscandomidestino, Unassigned)

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 When I load the following code (form that only contains hidden fields), this error appear: Error: document.getElementById("fm") has no properties If I put some text or non input hidden the code works fine Reproducible: Always Steps to Reproduce: Check this code <form name="fm" id="fm" action="javascript:alert('hello');" method="get"> <input type="hidden" name="urlRetorno" value=""> <input type="hidden" name="salir" value=""> <input type="hidden" name="urlRel" value="javascrit:window.close()"> <input type="hidden" name="status" value=""> </form> <script> document.getElementById("fm").submit(); </script> if you replace for this <form name="fm" id="fm" action="javascript:alert('hello');" method="get"> TEXT <input type="hidden" name="urlRetorno" value=""> <input type="hidden" name="salir" value=""> <input type="hidden" name="urlRel" value="javascrit:window.close()"> <input type="hidden" name="status" value=""> </form> <script> document.getElementById("fm").submit(); </script> It load correctly
Attached file reduced testcase? (deleted) —
With this testcase, Gecko's HTML parser puts the script in HEAD and the div in BODY, so the script gets evaluated first and can't see the div. Nasty! Note that this goes away if you add text to the div (consistent with comment 0) or if you add a <body> at the top.
Status: UNCONFIRMED → NEW
Component: Error Console → HTML: Parser
Ever confirmed: true
Keywords: testcase
OS: Windows XP → All
Product: Firefox → Core
QA Contact: error.console → parser
Hardware: PC → All
Version: unspecified → Trunk
Summary: Javascript error when I do getElementsById in a form that only have hidden inputs → HTML parser ships <script> to implicit <head>, breaking getElementById in inline script
1.9 _would have_ been a good time to fix this, too...
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
If that's really a dupe, then the summary of the other bug should be changed.
Done.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: