Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do I get a null or not an object error?

Object Referencing

Why do I get a null or not an object error?

by  onpnt  Posted    (Edited  )
Two main reasons for this error.
1) A script is loaded before the body content is loaded.
Fix: place the script in a function and call it on a event or (not recommended) place the script below the
body content just above the closing </body> tag
1) You are referencing a parent to child object in the wrong sequence.
Fix:
Use this reference to navigate through the objects and their child objects on a page.
This is a common error in many scripts.
For example
document.radio name is an error
document.form name.radio name is valid

window
|
+-------parent, frames, self, top
|
+-------location
|
+-------history
|
+-------document
|
+--forms
| |
| elements (text fields, textarea, checkbox, password
| radio, select, button, submit, reset)
+--links
|
+--anchors

also on a last note: the need for window.document or window.location has been far long gone.
Unless your viewer is running the
first version of NN or IE it is not needed.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top