Chapter 17. The Document Object Model
A
document object model (DOM) is an application programming interface (API)
for representing a document (such as an HTML document) and accessing
and manipulating the various elements (such as HTML tags and strings
of text) that make up that document. JavaScript-enabled web browsers
have always defined a document object model; a web-browser DOM may
specify, for example, that the forms in an HTML document are
accessible through the forms[]
array of the
Document object.
In this chapter, we’ll discuss the W3C DOM, a standard document object model defined by the World Wide Web Consortium and implemented (at least partially) by Netscape 6 and Internet Explorer 5 and 6. This DOM standard[54] is a full-featured superset of the traditional web-browser DOM. It represents HTML (and XML) documents in a tree structure and defines properties and methods for traversing the tree and examining and modifying its nodes. Other portions of the standard specify techniques for defining event handlers for the nodes of a document, working with the style sheets of a document, and manipulating contiguous ranges of a document.
This chapter begins with an overview of the DOM standard and then describes the core portions of the standard for working with HTML documents. The discussion of the core standard is followed by short sections that explain the DOM-like features of Internet Explorer 4 and Netscape 4. The chapter ends with an overview of two optional parts of the DOM ...
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.