FORM tag not accessable via JavaScript with external CSS sheet link or external script

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
--
major
RESOLVED FIXED
16 years ago
11 years ago

People

(Reporter: Alexander Zink, Unassigned)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

16 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1a) Gecko/20020611
BuildID:    20020611

See the HTML file listed below:
After the FORM tag starts in the body section of the upper frame (thus directly
after the opening FORM tag) in the BODY section, it should be immedately
available for JavaScript (DOM) access, and indeed it IS with all other major
HTML browser applications (including Netscape 4.7)! But Mozilla 1.1a does not
make this item accessable - the FORM element count in the document stays at 0! 
If the user then presses Ctrl-R (refresh) instead of re-loading the page through
the address line in the toolbar, Mozilla will work fine and report 1 available
FORM elment...

The problem is caused by the externally linked CSS file in the header! If this
LINK statement is removed or replaced by an internal CSS definition, Mozilla
works fine and makes the FORM tag immedately available. It is not important
which content the externally referenced CSS file contains - or if it even
exists! The pure presence of the LINK statement seems to disturb the
JavaScript/DOM functionality...

Reproducible: Always
Steps to Reproduce:
Load the provided HTML demo file and see the HTML code in the upper frame
('frame1'), which will be written dynamically by the provided JavaScript code of
the base page.

Actual Results:  After the opening FORM tag in the body section of 'frame1', the
FORM element should be immedately available for JavaScript access. With the LINK
header element present in the header section of 'frame1', this functionality is
broken.

Expected Results:  Mozilla 1.1a must behave as every other major browser and
make the FORM element immedately available to internal scripting - fully
independent from the presence or absence of a LINK statement in the header section!

<html>
<head>
  <title>Test</title>
  
  <script type="text/javascript">
   function WriteFrame1()
   {
     d = top.frame1.document;
     d.write( "<html>\n<head>\n<title>Test-Frame</title>\n" );

       /* Remove the following line (or rename 'link' to e.g. 'xlink') to get
Mozilla 1.0 to behave correctly 
          (thus making the <form> element available in the DOM immediately after
it was written to 'frame1')! 
          The problem does not depond on whether the external css file actually
exists or which element formats it defines! */
     d.write( "<link rel=\"stylesheet\" type=\"text/css\"
href=\"anything.css\">\n" );

     d.write( "</head>\n<body>\n" );
     d.write( "<form name=\"form1\">\n" );
     
     d.writeln( "Remove the external-CSS &lt;link&gt; element from the
JavaScript section of the html document, and Mozilla 1.0 will recognize the
&lt;form&gt; element immediately (like every other browser)!" );
     alert( "Number of forms in document: " + top.frame1.document.forms.length +
"\n Types of document: " + typeof( top.frame1.document) + "\n Type of form1: " +
typeof( top.frame1.document.form1 ) );
     
     d.write( "</form>\n" );
     d.write( "</body>\n</html>" );
     d.close();
     
     alert( "Number of forms in document: " + top.frame1.document.forms.length +
"\n Types of document: " + typeof( top.frame1.document) + "\n Type of form1: " +
typeof( top.frame1.document.form1 ) );

     return( true );
   }
  </script>
</head>

<frameset rows="*,1" onLoad="WriteFrame1()">
  <frame src="about:blank" name="frame1">
  <frame src="about:blank" name="frame2">
</frameset>
</html>

Comment 1

16 years ago
Created attachment 90599 [details]
Testcase from bugreport
Created attachment 90604 [details]
Same, but with <script>
This has nothing to do with the JS engine... The problem, it seems to me, is
that the parser-blocking magic that <script> and <link> do leads to us executing
that alert before he (blocked) content model s built...

As a note, this is why you generally want to hook into onload() events....
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: FORM tag not accessable via JavaScript with external CSS link → FORM tag not accessable via JavaScript with external CSS sheet link or external script
*** Bug 158905 has been marked as a duplicate of this bug. ***
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
Depends on: 84582
Fixed for <link> by bug 84582.

The script thing is compat with other browsers, I think, so nothing to fix there.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.