Java Reference
In-Depth Information
Understanding Document Object Model
The Document Object Model (DOM) is a series of JavaScript objects that allows a Java-
Script application to access and modify both XML and HTML information. There are two
primary functions that most AJAX web sites use the DOM for. They are summarized here:
• Parsing XML received from the web server
• Making dynamic changes to the web page displayed on the browser
When the web server sends an HTML document to the web browser, the web browser
has a copy of the document, separate from the web server. This separate copy, which the web
browser stores in memory, is the copy of the web page that the user is looking at. Using the
DOM, it is possible for a JavaScript program to make changes to the copy of the web page the
user is viewing. This allows the browser to update individual parts of the document, but does
not change the document on the web server.
This is how AJAX gets by with not having to update the entire page. AJAX applications
use the DOM to update parts of the page in response to packets sent to the AJAX applica-
tion from the web server. It is also important to note that when AJAX updates the HTML of a
page, only the local browser copy is changed. The actual HTML on the web server is never
changed.
It is very easy to view a web page as it is seen from the DOM. For example, consider the
web page stored at the following URL:
http://www.httprecipes.com/1/10/example1.html
This page stores a simple table and some text. You can see this web page in Figure 10.1.
Search WWH ::




Custom Search