Last Modified: 1/29/08
  Computer Training
The Document Object Model


Credit: Mulchaey et al (ST Sci/UMD/NASA)

The Document Object Model (DOM) is that set of hierarchical classes and objects and their elements that belong to the Document part of a Web page, but can also be extended to include the entire Web structure from the main Window on down as depicted here . The names and references used in this DOM are very similar in Netscape and Internet Explorer for ordinary HTML, but differ greatly for Dynamic HTML (DHTML). Also, see here for how this elements can be listed.

The key to successful navigation is understanding how these objects and elements are referenced. Most can be referenced either by name or by index, as demonstrated in this example.

In a similar manner you can refer to images that appear in <IMG SRC...> statements either by name or by document.images[0], document.images[1], You can not only go down the hierarchy, but up as well. Thus if you are in an element inside a form, then this.form.elements[2] refers to the 3rd (sibling) element of that form.

The value property can be confusing. The rules are:

  • for Text and TextArea the "value" is what you type in
  • for Radio and Checkboxes, the "value" is what appears in the 'VALUE=..' part of the element, e.g., VALUE="home". But to determine if that value is selected you use the checked property
  • the select has the "value" listed in its list of "OPTION VALUE=" values. The one that is selected is its value.

Frames are independently scrollable areas in a window that behave very much like independent windows. See this for an example of how to reference and manipulate Frames in HTML.

Previous Home Next

Course Topics

Major Concepts in JavaScript

Execution of JavaScript Programs

JavaScript Statements and Structures

JavaScript as an Object Oriented Language

The Document Object Model

Programming with JavaScript

JavaScript and DHTML

Using Cookies in JavaScript

Using JavaScript to Write HTML

 
Previous Home Next

©1999 UW Technology