See following(first) attachment. The first script doesn't work because document.form1 has no property. But in the second form(form2), only difference with form1 is there are some text after the hidden input. Very interesting problem... But I'm not sure whether this is a known but, just file it as UNCONFIRMED. Could anyone confirm it or tell me which but it duplicate with?
*** Bug 153541 has been marked as a duplicate of this bug. ***
You test case starts with <html></body> If you correct this with <html><body>, the test case will work corectly.
To parser since this looks like a parsing issue
The first testcase is the only relevant one; the rearranging of the content model seems to trip up the form, although I don't quite understand how.
I see this, WinXP 2003012908.
It looks like the parser has explicit code to handle the following case: If we have not seen a <body> tag and we see a <script> tag, move that <script> tag over under the <head> tag. In the process, the <script> is actually appended to the document _before_ the <form> is, which causes all sorts of fun stuff to happen. See CNavDTD::HandleStartToken I suspect that code is there for a reason, and that removing or changing it should not be undertaken lightly...
*** This bug has been marked as a duplicate of 178258 ***