solution found: RE: [thelist] accessing a form within a div created on-the-fly

Peter-Paul Koch ppk at xs4all.nl
Mon Aug 14 12:23:07 CDT 2000


>In playing around with explicitly trying to add the form to the forms array,
>I've discovered that IE5 will only let me access the form via 
>
>   document.forms(i)
>
>not 
>
>    document.all.forms(i)
>

Hmmm...you're right, IE will accept forms(0). Be warned, however, that
Netscape (4 and M17) require forms[0], so your script will only generate
JavaScript errors.

>despite the fact that the form is within a div.  Weird?  I have much
learning to do.

It's because document.forms[], like document.images[], is a part of the DOM
that predates document.layers and document.all . It was already present in
the Version 3 browsers and when the Version 4 browsers were released they
still supported it because these arrays were so much used on the WWW, even
though, you're right, they didn't entirely fit within the new DOM concept.

Only Netscape 4 is different: when you create a layer (by giving a DIV a
'position') the form is suddenly only accessible through
document.layername.document.forms[0]

Gecko M17 again supports the old way.

ppk




More information about the thelist mailing list