Matt Kruse said the following on 12/8/2005 7:45 PM:[color=blue]
> Given the following in the <body> of an HTML page:
>
> <form name="test" action="action">
> <input name="test1" value="abc">
> <script type="text/javascript">
> alert(document.forms['test'].elements['test1'].value);
> </script>
>
> I have two questions:
>
> 1. Is there anything in the specs/standards that says the <form> and <input>
> objects must be available for reference in the DOM as soon as they are
> parsed in the document, so that the script will succeed? I couldn't find
> anything.[/color]
No.
[color=blue]
> 2. If nothing is in the specs/standards, then does anyone know of any
> browsers which would not make the objects available for script immediately?[/color]
None that I know of. May be others though that are not on Win based
systems that know/have one that doesn't.
[color=blue]
> I'm wondering if, for example, a browser would only make the DOM available
> to script once it is fully loaded and parsed?[/color]
The only time you can be sure that the DOM is available is indeed to
wait until it is fully loaded and parsed. Trying to access it before
then is going to lead into problems.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/