473,545 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DOM objects immediately available to script?

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.

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?
I'm wondering if, for example, a browser would only make the DOM available
to script once it is fully loaded and parsed?

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Dec 9 '05 #1
1 1473
Matt Kruse said the following on 12/8/2005 7:45 PM:
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.
No.
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?
None that I know of. May be others though that are not on Win based
systems that know/have one that doesn't.
I'm wondering if, for example, a browser would only make the DOM available
to script once it is fully loaded and parsed?


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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
497
by: user | last post by:
Say I have a database object 'db', that contains table objects, that contain field objects so that I can do things like this: print db.table.field.value() Now, after plundering the database for a while, the db objects heads a tree of lots of data.
2
1879
by: Weston C | last post by:
I'm wondering if it's possible to add a method to the Node and/or Element objects (so they'd subsequently be available to any node/element). I'd assume you could just do something like: n.myNewMethod = function myNewMethod; where n is any Node -- but the fact that Nodes and Elements are explicitly definied as interfaces rather than actual...
8
1941
by: vvenk | last post by:
Hello: I just wrote my first ASP.Net application. It worked fine on my machine and when I put into production, the ASP.Net process reaches 50% quite fast and then the system does not work anymore until I kill that process. Obviously, this is not acceptable. Looking back, I do not destroy any objects in my form. Would that be the reasn...
6
1060
by: gabe | last post by:
I have question about code standards in VS 2005 I have been declaring objects before a try block in case I would ever want to refer to them in 'Catch' block. When I converted my apps to 2.0 I get warnings that objects have been declared, but not initialized. I've hesitated to actually 'New' an object outside of a try in the event of an...
0
1021
by: Matti Airas | last post by:
Hi all, I've been toying with an idea of dependency-based coding, in which you construct a graph of code dependencies. Say, you have independent variables 'a' and 'b', and a function f(x,y). Now, you can define that a,b are dependencies for f(a,b). Whenever a or b are changed, f(a,b) is marked dirty, and if its value is requested, all the...
20
1876
by: walterbyrd | last post by:
Reading "Think Like a Computer Scientist" I am not sure I understand the way it describes the way objects work with Python. 1) Can attributes can added just anywhere? I create an object called point, then I can add attributes any time, and at any place in the program? 2) Are classes typically created like this: class Point:
6
2242
by: Tim Hunter | last post by:
I am using Access 2003 under WinXP. I currently support a huge Excel Wokbook that is a maintenance nightmare. There are about 15 worksheets each with lots of formulas...Anyway I am thinking of converting this application to an Access solution and specifically using Class Objects. I am comfortable with Access but I have never worked with...
66
3649
by: karthikbalaguru | last post by:
Hi, Will 'free' return the memory Immediately to the OS ? Thx in advans, Karthik Balaguru
2
1873
by: BobLewiston | last post by:
The concept of delegates (references to methods) per se is new to me (although I used function pointers in C years ago), and although the literature acknowledges that there are significant differences between delegates and the use of pointers to objects, I'm nonetheless a little confused by how similar the syntax used for references to methods is...
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.