Document — an HTML or XML document
A Document object is a Node that serves as the root of a
document tree. The
property is the root Element of the document. A Document
node may have other children (such as Comment and DocumentType
nodes), but it has only one Element child that holds all the content
of the document.
You most commonly obtain a Document object via the
document property of a Window. Document
objects are also available through the
contentDocument property of IFrame
elements or the
property of any Node.
Most of the properties of a Document object provide access to elements of the document or to other important objects associated with the document. A number of Document methods do the same thing: provide a way to look up elements within the document tree. Many other Document methods are “factory methods” that create elements and related objects.
Documents, like the Elements they contain, are event targets. They implement the methods defined by EventTarget, and they also support quite a few event handler properties.
You can create new Document objects by using the
Document() methods of the
It is also possible to load an HTML or XML file from the
network and parse it into a Document object. See the
responseXML property of the XMLHttpRequest object.
The reference entry for HTMLDocument, which appeared in previous versions ...