All Topics  
Document Object Model

 

   Email Print
   Bookmark   Link






 

Document Object Model



 
 
The Document Object Model (DOM) is a platform- and language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
-independent standard object model
Object model

In computing, object model has two related but distinct meanings:# The properties of object in general, in a specific computer programming language, technology, notation or methodology that uses them....
 for representing HTML
HTML

HTML, an Acronym and initialism of HyperText Markup Language, is the predominant markup language for Web pages. It provides a means to describe the structure of text-based information in a document?by denoting certain text as links, headings, paragraphs, lists, and so on?and to supplement that text with interactive forms, embedded '...
 or XML documents as well as an Application Programming Interface
Application programming interface

An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications....
 (API) for querying, traversing and manipulating such documents.

Legacy DOM
JavaScript was released by Netscape Communications in 1996 as part of Netscape Navigator 2.0.






Discussion
Ask a question about 'Document Object Model'
Start a new discussion about 'Document Object Model'
Answer questions from other users
Full Discussion Forum



Recent Posts









Encyclopedia


The Document Object Model (DOM) is a platform- and language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
-independent standard object model
Object model

In computing, object model has two related but distinct meanings:# The properties of object in general, in a specific computer programming language, technology, notation or methodology that uses them....
 for representing HTML
HTML

HTML, an Acronym and initialism of HyperText Markup Language, is the predominant markup language for Web pages. It provides a means to describe the structure of text-based information in a document?by denoting certain text as links, headings, paragraphs, lists, and so on?and to supplement that text with interactive forms, embedded '...
 or XML documents as well as an Application Programming Interface
Application programming interface

An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications....
 (API) for querying, traversing and manipulating such documents.

History


The history of the Document Object Model is intertwined with the history of the "browser wars
Browser wars

The term "browser wars" refers to the competition for dominance in the web browser marketplace. The term is used to denote two specific periods of time: the competition between market-dominating Netscape Navigator and its eventual defeat by Microsoft Internet Explorer during the late 1990s, and the competition from 2003 onwards between the d...
" of the late 1990s between Netscape Navigator
Netscape Navigator

Netscape Navigator and Netscape are the names for the proprietary software web browser popular in the 1990s, and the flagship product of the Netscape Communications Corporation, and the dominant web browser in terms of Usage share of web browsers....
 and Microsoft Internet Explorer, as well as that of JavaScript
JavaScript

JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard....
 and JScript
JScript

JScript is the Microsoft dialect of the ECMAScript scripting language specification.JavaScript , JScript, and ECMAScript are very similar languages....
, the first scripting language
Scripting language

A scripting language, script language or extension language, is a programming language that allows some control of a single or many Application software....
s to be widely implemented in the layout engines of web browsers.

Legacy DOM


JavaScript was released by Netscape Communications in 1996 as part of Netscape Navigator 2.0. Netscape's competitor, Microsoft
Microsoft

Microsoft Corporation is a multinational corporation computer technology corporation that develops, manufactures, licenses, and supports a wide range of computer software products for computing devices....
 released Internet Explorer 3.0 later the same year with a port of JavaScript called JScript. JavaScript and JScript enabled web developer
Web developer

A web developer is a software developer or software engineer who is specifically engaged in the development of World Wide Web applications, or distributed network applications that are run over the [] protocol from a web server to a web browser....
s to create web pages with client-side
Client-side

In computer networking, the term client-side refers to operations that are performed by the Client in a client-server relationship.Typically, a client is a computer application, such as a web browser, that runs on a user 's local computer or workstation and connects to a server as necessary....
 interactivity. The limited facilities for detecting user-generated events
Event (computing)

In computing an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program....
 and modifying the HTML document in the first generation of these languages eventually became known as "DOM Level 0" or "Legacy DOM". No independent standard was developed for DOM Level 0, but it was partly described in the specification of HTML4.

Legacy DOM was limited in the kinds of element
HTML element

In computing, an HTML element indicates structure in an HTML document and a way of hierarchically arranging content. More specifically, an HTML element is an Standard Generalized Markup Language element that meets the requirements of one or more of the HTML Document Type Definitions ....
s that could be accessed. Form
Form (web)

A webform on a web page allows a user to enter data that is sent to a Server for processing. Webforms resemble form because internet users fill out the forms using checkboxes, radio buttons, or menus....
, link
Hyperlink

In computing, a hyperlink, usually shortened to link, is a directly followable reference within a hypertext document.The area from which the hyperlink can be activated is called its anchor; its target is what the link points to, which may be another location within the same page or document, another page or document, or a...
 and image elements could be referenced with a hierarchical name that began with the root document object. A hierarchical name could make use of either the names or the sequential index of the traversed elements. For example, a form input element
Text box

A text box, text field or text entry box is a common element of graphical user interface of computer programs, as well as the corresponding type of widget used when programming GUIs....
 could be accessed as either "document.formName.inputName" or "document.forms[0].elements[0]".

The Legacy DOM enabled client-side form validation and the popular "rollover
Rollover (web design)

Rollover refers to a button as created by a web developer or web designer, found within a web page, used to provide interactivity between the user and the page itself....
" effect.

Intermediate DOM


In 1997, Netscape and Microsoft released version 4.0 of Netscape Navigator and Internet Explorer, adding support for Dynamic HTML
Dynamic HTML

Dynamic HTML, or DHTML, is a collection of technologies used together to create interactive and animated web sites by using a combination of a static markup language , a client-side scripting language , a presentation definition language , and the Document Object Model....
 (DHTML), functionality enabling changes to a loaded HTML document. DHTML required extensions to the rudimentary document object that was available in the Legacy DOM implementations. Although the Legacy DOM implementations were largely compatible since JScript was based on JavaScript, the DHTML DOM extensions were developed in parallel by each browser maker and remained incompatible. These versions of the DOM became known as the "Intermediate DOM."

The Intermediate DOMs enabled the manipulation of Cascading Style Sheet (CSS) properties which influence the display of a document. They also provided access to a new feature called "layers" via the "document.layers" property (Netscape Navigator) and the "document.all" property (Internet Explorer). Because of the fundamental incompatibilities in the Intermediate DOMs, cross-browser
Cross-browser

Cross-browser refers to the ability for a website, web application, HTML construct or client-side scripting to support all the web browsers. The term cross-browser is often confused with multi-browser....
 development required special handling for each supported browser.

Subsequent versions of Netscape Navigator abandoned support for its Intermediate DOM. Internet Explorer continues to support its Intermediate DOM for backwards compatibility.

Standardization


The World Wide Web Consortium
World Wide Web Consortium

The World Wide Web Consortium is the main international standards organization for the World Wide Web . It is arranged as a consortium where member organizations maintain full-time staff for the purpose of working together in the development of standards for the World Wide Web....
 (W3C), founded in 1994 to promote open standards for the World Wide Web
World Wide Web

The World Wide Web is a very large set of interlinked hypertext documents accessed via the Internet. With a Web browser, one can view Web pages that may contain writing, s, videos, and other multimedia and navigate between them using hyperlinks....
, brought Netscape Communications and Microsoft together with other companies to develop a standard for browser scripting languages, called "ECMAScript
ECMAScript

ECMAScript is a scripting language, standardized by Ecma International in the ECMA-262 Specification . The language is widely used on the World Wide Web, and is often confused with JavaScript or JScript, the two major Programming language dialect from which ECMAScript was standardized....
". The first version of the standard was published in 1997. Subsequent releases of JavaScript and JScript would implement the ECMAScript standard for greater cross-browser compatibility.

After the release of ECMAScript, W3C began work on a standardized DOM. The initial DOM standard, known as "DOM Level 1," was recommended by W3C in late 1998. About the same time, Internet Explorer 5.0 shipped with limited support for DOM Level 1. DOM Level 1 provided a complete model for an entire HTML or XML document, including means to change any portion of the document. Non-conformant browsers such as Internet Explorer 4.x and Netscape 4.x were still widely used as late as 2000.

DOM Level 2 was published in late 2000. It introduced the "getElementById" function as well as an event model
DOM Events

DOM events allow event-driven programming languages like JavaScript, JScript, ECMAScript, VBScript and Java to register various event handlers/event listeners on the element nodes inside a Document Object Model tree, e.g....
 and support for XML namespaces and CSS. DOM Level 3, the current release of the DOM specification, published in April 2004, added support for XPath
XPath

XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document....
 and keyboard event handling, as well as an interface for serializing
Serialization

In computer science, in the context of data storage and transmission, serialization is the process of converting an object into a sequence of bits so that it can be stored on a storage medium or transmitted across a computer network connection link....
 documents as XML.

By 2005, large parts of W3C DOM were well-supported by common ECMAScript-enabled browsers, including Microsoft Internet Explorer version 6 (2001), Gecko
Gecko (layout engine)

Gecko is a layout engine currently developed by Mozilla Corporation, known as the layout engine of the Mozilla Firefox web browser, Mozilla Application Suite, Nvu, Mozilla Thunderbird and many more....
-based browsers (like Mozilla
Mozilla Application Suite

The Mozilla Application Suite is a cross-platform integrated Internet suite. Its development was initiated by Netscape Communications Corporation, before their acquisition by AOL....
, Firefox
Mozilla Firefox

Mozilla Firefox is a web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. Official versions are distributed under the terms of the proprietary EULA....
 and Camino
Camino

Camino is a free software, open source, graphical user interface Web browser based on Mozilla Foundation's Gecko and specifically designed for the Mac OS X operating system....
), Konqueror
Konqueror

Konqueror is a web browser, file manager and file viewer designed as a core part of the KDE. It is developed by volunteers and can run on most Unix-like operating systems....
, Opera
Opera (web browser)

Opera is a web browser and Internet suite developed by the Opera Software company. Opera handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, IRC online chatting, downloading files via BitTorrent , and reading web feeds....
, and Safari
Safari (web browser)

Safari is a web browser developed by Apple Inc.. First released as a beta on January 7, 2003 on the company's Mac OS X operating system, it became Apple's default browser beginning with Mac OS X v10.3, commonly known as "OS X Panther." Apple has also made Safari the native browser for the iPhone OS....
.

Applications


DOM is likely to be best suited for applications where the document must be accessed repeatedly or out of sequence order. If the application is strictly sequential and one-pass
One-pass algorithm

In computing, a one-pass algorithm is one which reads its input exactly once, in order, without unbounded Buffer . A one-pass algorithm generally requires O time and less than O storage , where n is the size of the input....
, the SAX
Simple API for XML

SAX is a serial access parser Application programming interface for XML. SAX provides a mechanism for reading data from an XML document. It is a popular alternative to the Document Object Model ....
 model is likely to be faster and use less memory. In addition, non-extractive XML parsing models, such as VTD-XML
VTD-XML

Virtual Token Descriptor for eXtensible Markup Language refers to a collection of efficient XML processing technologies centered around a non-extractive XML, "document-centric" parsing technique called Virtual Token Descriptor ....
, provide a new memory-efficient option.

Web browsers


A web browser is not obliged to use DOM in order to render an HTML document. However, the DOM is required by JavaScript scripts that wish to inspect or modify a web page dynamically. In other words, the Document Object Model is the way JavaScript sees its containing HTML page and browser state.

Implementations


Because DOM supports navigation in any direction (e.g., parent and previous sibling) and allows for arbitrary modifications, an implementation must at least buffer the document that has been read so far (or some parsed form of it).

Layout engines


Web browsers rely on layout engines to parse HTML into a DOM. Some layout engines such as Gecko or Trident/MSHTML
Trident (layout engine)

Trident is the name of the layout engine for the Microsoft Windows version of Internet Explorer. It was first introduced with the release of Internet Explorer 4 in October 1997; it has been steadily upgraded and remains in use today....
 are associated primarily or exclusively with a particular browser such as Firefox or Internet Explorer. Others, such as WebKit
WebKit

WebKit is an application framework that provides a foundation upon which to build a web browser. WebKit was originally derived by Apple Inc. from the Konqueror browser?s KHTML software library for use as the engine of Mac OS X?s Safari web browser, and has now been further developed by individuals from the KDE project, Apple, Nokia, Google,...
, are shared by a number of browsers, such as Safari and Google Chrome
Google Chrome

Google Chrome is a web browser developed by Google and based on the WebKit layout engine and application framework.In February 2009, it had a share of 1.15% of the web browser market....
. Various layout engines implement the DOM standards to varying degrees.
Comparison of layout engines (DOM)

The following tables compare Document Object Model compatibility and support for a number of layout engines. Please see the individual products' articles for further information....


Libraries


  • JAXP
    Java API for XML Processing

    The Java API for XML Processing, or JAXP , is one of the Java XML programming Application programming interfaces. It provides the capability of validating and parsing XML documents....
     (Java API for XML Processing)
  • libxml2
  • MSXML
    MSXML

    Microsoft XML Core Services is a set of services that allow applications written in JScript, VBScript, and Microsoft development tools to build Windows-native XML-based applications....
  • VTD-XML
    VTD-XML

    Virtual Token Descriptor for eXtensible Markup Language refers to a collection of efficient XML processing technologies centered around a non-extractive XML, "document-centric" parsing technique called Virtual Token Descriptor ....
     for building SOA intermediary applications
  • Xerces
    Xerces

    Xerces is a family of software packages for parser and manipulating XML, formerly a part of the Apache Software Foundation XML project and now an Apache project in its own right....


See also


  • DOM scripting
    DOM scripting

    The term DOM Scripting refers to programmatically accessing the Document Object Model . In common usage, DOM scripting implies JavaScript. DOM Scripting has its roots in DHTML, but is more structured....
  • JDOM
    JDOM

    JDOM is an open source Java -based document object model for XML that was designed specifically for the Java platform so that it can take advantage of its language features....
     - a Java-based document object model for XML that integrates with DOM and SAX and uses parsers to build the document.
  • SXML
    SXML

    SXML is a way to write and process XML data in the form of S-expressions.Textual correspondence between SXML and XML for a sample XML snippet is shown below:...
     - a model for representing XML and HTML in the form of S-expressions.
  • Ajax
    Ajax (programming)

    Ajax, or AJAX , is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications....
     - a methodology employing DOM in combination with techniques for retrieving data without reloading a page.
  • TinyXml
    TinyXML

    TinyXML is a very small and simple XML parser for the C++ language. It ignores Document Type Definition, and it is free and open source software, distributed under the terms of the license of zlib/libpng....
     - efficient platform-independent XML library for C++.


External links


  • (Quirksmode)
  • (Mozilla Developer Center)
  • [https://studio.tellme.com/dom/ref/ DOM Reference] (Tellme)


Specifications


  • Level 2 Recommendations:
  • Level 3 Recommendations:
  • Level 3 Working Group Notes:
  • Working Draft


Bindings


  • [https://libre.adacore.com/xmlada/ Ada]
  • C++: ,
  • Common Lisp: , ,
  • - W3C Document Object Model Level 2
  • (Kylix programming tool
    Kylix programming tool

    Kylix is a compiler and integrated development environment formerly sold by Borland but later discontinued. It is a Linux version of the Borland Delphi programming language and C++ Builder, which run under Microsoft Windows....
    )