mozilla

Revision 10499 of Document

  • Revision slug: DOM/document
  • Revision title: document
  • Revision id: 10499
  • Created:
  • Creator: Pmsyyz
  • Is current revision? No
  • Comment [[DOM]] link obsoletes breadcrumbs

Revision Content

{{template.DomRef()}}

In the DOM, the document object provides a general way to represent HTML, XHTML, and XML documents. Document objects implement the general DOM Core document interface.

In addition to the generalized DOM Core document interface, HTML documents also implement the DOM HTMLDocument interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor). Properties and methods listed here that are part of this more specialized interface have an asterisk (*) next to them.

The document is contained by the window object and may contain any number of elements.

The document interface provides access to things such as the document type, its color and formatting, plugins and applets, as well providing methods for creating and manipulating all of the document's child nodes, or elements, such as BODY and TABLE elements.

Properties

document.alinkColor* {{template.Deprecated_inline()}}
Returns or sets the color of active links in the document body.
document.anchors*
anchors returns a list of all of the anchors in the document.
document.applets*
applets returns an ordered list of the applets within a document.
document.bgColor* {{template.Deprecated_inline()}}
bgColor gets/sets the background color of the current document.
document.body*
body returns the BODY node of the current document.
document.characterSet
Returns the character set being used by the document.
document.compatMode*
Indicates whether the document is rendered in Quirks or Strict mode.
document.contentType
Returns the Content-Type from the MIME Header of the current document.
document.cookie*
Returns a semicolon-separated list of the cookies for that document or sets a single cookie.
document.defaultView
Returns a reference to the window object.
document.designMode*
designMode gets/sets WYSYWIG editing capability of Midas. It can only be used for HTML documents.
document.doctype
Returns the Document Type Definition (DTD) of the current document.
document.documentElement
Returns the Element that is a direct child of document. For HTML documents, this normally the HTML element.
document.domain*
domain returns the domain of the current document.
document.embeds*
embeds returns a list of the embedded OBJECTS within the current document.
document.fgColor* {{template.Deprecated_inline()}}
fgColor gets/sets the foreground color, or text color, of the current document.
document.firstChild
firstChild returns the first node in the list of direct children of the document. (See also firstChild for the general element property.)
document.forms*
forms returns a list of the FORM elements within the current document.
document.height*
height gets/sets the height of the current document.
document.images*
images returns a list of the images in the current document.
document.implementation*
Returns the DOM implementation associated with the current document.
document.lastModified*
Returns the date on which the document was last modified.
document.linkColor* {{template.Deprecated_inline()}}
Gets/sets the color of hyperlinks in the document.
document.links*
Returns a list of all the hyperlinks in the document.
document.location*
Returns the URI of the current document.
document.namespaceURI
Returns the XML namespace of the current document.
document.plugins*
Returns a list of the available plugins.
document.referrer*
Returns the URI of the page that linked to this page.
document.styleSheets*
Returns a list of the stylesheet objects on the current document.
document.title*
Returns the title of the current document.
document.URL
Returns a string containing the URL of the current document.
document.vlinkColor* {{template.Deprecated_inline()}}
Gets/sets the color of visited hyperlinks.
document.width*
Returns the width of the current document.

Methods

document.clear* {{template.Deprecated_inline()}}
In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.
document.close*
Closes a document stream for writing.
document.createAttribute
Creates a new attribute node and returns it.
document.createDocumentFragment
Creates a new document fragment.
document.createElement
Creates a new element with the given tag name.
document.createElementNS
Creates a new element with the given tag name and namespace URI.
document.createEvent
Creates an event.
document.createNSResolver
Creates an XPathNSResolver.
document.createRange
Creates a Range object.
document.createTextNode
Creates a text node.
document.evaluate
Evaluates an XPath expression.
document.execCommand*
Executes a Midas command.
document.getElementById
Returns an object reference to the identified element.
document.getElementsByName
Returns a list of elements with the given name.
document.getElementsByTagName
Returns a list of elements with the given tag name.
document.getElementsByTagNameNS
Returns a list of elements with the given tag name and namespace.
document.importNode
Returns a clone of a node from an external document.
document.loadOverlay
Loads a XUL overlay dynamically. This only works in XUL documents.
document.open*
Opens a document stream for writing.
document.queryCommandEnabled*
Returns true if the Midas command can be executed on the current range.
document.queryCommandIndeterm*
Returns true if the Midas command is in a indeterminate state on the current range.
document.queryCommandState*
Returns true if the Midas command has been executed on the current range.
document.queryCommandValue*
Returns the current value of the current range for Midas command.
document.write*
Writes text to a document.
document.writeln*
Write a line of text to a document.
{{ wiki.languages( { "fr": "fr/DOM/document", "ja": "ja/DOM/document", "pl": "pl/DOM/document" } ) }}

Revision Source

<p>{{template.DomRef()}}
</p><p>In the <a href="en/DOM">DOM</a>, the <b>document object</b> provides a general way to represent <a href="en/HTML">HTML</a>, <a href="en/XHTML">XHTML</a>, and <a href="en/XML">XML</a> documents. Document objects implement the general <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document">DOM Core document</a> interface.
</p><p>In addition to the generalized DOM Core document interface, HTML documents also implement the <a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268">DOM HTMLDocument</a> interface, which is a more specialized interface for dealing with HTML documents (e.g., <a href="en/DOM/document.cookie">document.cookie</a>, <a href="en/DOM/document.alinkColor">document.alinkColor</a>). Properties and methods listed here that are part of this more specialized interface have an asterisk (*) next to them.
</p><p>The document is contained by the <a href="en/DOM/window">window</a> object and may contain any number of <a href="en/DOM/element">elements</a>.
</p><p>The document interface provides access to things such as the document type, its color and formatting, plugins and applets, as well providing methods for creating and manipulating all of the document's child nodes, or elements, such as BODY and TABLE elements.
</p>
<h3 name="Properties"> Properties </h3>
<dl><dt> <a href="en/DOM/document.alinkColor">document.alinkColor</a>* {{template.Deprecated_inline()}}
</dt><dd> Returns or sets the color of active links in the document body.
</dd></dl>
<dl><dt> <a href="en/DOM/document.anchors">document.anchors</a>*
</dt><dd> <b>anchors</b> returns a list of all of the anchors in the document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.applets">document.applets</a>*
</dt><dd> <b>applets</b> returns an ordered list of the applets within a document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.bgColor">document.bgColor</a>* {{template.Deprecated_inline()}}
</dt><dd> <b>bgColor</b> gets/sets the background color of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.body">document.body</a>*
</dt><dd> <b>body</b> returns the BODY node of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.characterSet">document.characterSet</a>
</dt><dd> Returns the character set being used by the document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.compatMode">document.compatMode</a>*
</dt><dd> Indicates whether the document is rendered in Quirks or Strict mode.
</dd></dl>
<dl><dt> <a href="en/DOM/document.contentType">document.contentType</a>
</dt><dd> Returns the Content-Type from the MIME Header of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.cookie">document.cookie</a>*
</dt><dd> Returns a semicolon-separated list of the cookies for that document or sets a single cookie.
</dd></dl>
<dl><dt> <a href="en/DOM/document.defaultView">document.defaultView</a>
</dt><dd> Returns a reference to the window object.
</dd></dl>
<dl><dt> <a href="en/DOM/document.designMode">document.designMode</a>*
</dt><dd> <b>designMode</b> gets/sets WYSYWIG editing capability of <a href="en/Midas">Midas</a>. It can only be used for HTML documents.
</dd></dl>
<dl><dt> <a href="en/DOM/document.doctype">document.doctype</a>
</dt><dd> Returns the Document Type Definition (DTD) of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.documentElement">document.documentElement</a>
</dt><dd> Returns the Element that is a direct child of document. For HTML documents, this normally the HTML element.
</dd></dl>
<dl><dt> <a href="en/DOM/document.domain">document.domain</a>*
</dt><dd> <b>domain</b> returns the domain of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.embeds">document.embeds</a>*
</dt><dd> <b>embeds</b> returns a list of the embedded OBJECTS within the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.fgColor">document.fgColor</a>* {{template.Deprecated_inline()}}
</dt><dd> <b>fgColor</b> gets/sets the foreground color, or text color, of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.firstChild">document.firstChild</a>
</dt><dd> <b>firstChild</b> returns the first node in the list of direct children of the document. (See also <a href="en/FirstChild">firstChild</a> for the general element property.)
</dd></dl>
<dl><dt> <a href="en/DOM/document.forms">document.forms</a>*
</dt><dd> <b>forms</b> returns a list of the FORM elements within the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.height">document.height</a>*
</dt><dd> <b>height</b> gets/sets the height of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.images">document.images</a>*
</dt><dd> <b>images</b> returns a list of the images in the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.implementation">document.implementation</a>*
</dt><dd> Returns the DOM implementation associated with the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.lastModified">document.lastModified</a>*
</dt><dd> Returns the date on which the document was last modified.
</dd></dl>
<dl><dt> <a href="en/DOM/document.linkColor">document.linkColor</a>*  {{template.Deprecated_inline()}}
</dt><dd> Gets/sets the color of hyperlinks in the document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.links">document.links</a>*
</dt><dd> Returns a list of all the hyperlinks in the document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.location">document.location</a>*
</dt><dd> Returns the URI of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.namespaceURI">document.namespaceURI</a>
</dt><dd> Returns the XML namespace of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.plugins">document.plugins</a>*
</dt><dd> Returns a list of the available plugins.
</dd></dl>
<dl><dt> <a href="en/DOM/document.referrer">document.referrer</a>*
</dt><dd> Returns the URI of the page that linked to this page. 
</dd></dl>
<dl><dt> <a href="en/DOM/document.styleSheets">document.styleSheets</a>*
</dt><dd> Returns a list of the <a href="en/DOM/stylesheet">stylesheet</a> objects on the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.title">document.title</a>*
</dt><dd> Returns the title of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.URL">document.URL</a>
</dt><dd> Returns a string containing the URL of the current document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.vlinkColor">document.vlinkColor</a>* {{template.Deprecated_inline()}}
</dt><dd> Gets/sets the color of visited hyperlinks.
</dd></dl>
<dl><dt> <a href="en/DOM/document.width">document.width</a>*
</dt><dd> Returns the width of the current document.
</dd></dl>
<h3 name="Methods"> Methods </h3>
<dl><dt> <a href="en/DOM/document.clear">document.clear</a>* {{template.Deprecated_inline()}}
</dt><dd> In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.
</dd></dl>
<dl><dt> <a href="en/DOM/document.close">document.close</a>*
</dt><dd> Closes a document stream for writing.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createAttribute">document.createAttribute</a>
</dt><dd> Creates a new attribute node and returns it.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createDocumentFragment">document.createDocumentFragment</a>
</dt><dd> Creates a new document fragment.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createElement">document.createElement</a>
</dt><dd> Creates a new element with the given tag name.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createElementNS">document.createElementNS</a>
</dt><dd> Creates a new element with the given tag name and namespace URI.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createEvent">document.createEvent</a>
</dt><dd> Creates an event.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createNSResolver">document.createNSResolver</a>
</dt><dd> Creates an XPathNSResolver.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createRange">document.createRange</a>
</dt><dd> Creates a Range object.
</dd></dl>
<dl><dt> <a href="en/DOM/document.createTextNode">document.createTextNode</a>
</dt><dd> Creates a text node.
</dd></dl>
<dl><dt> <a href="en/DOM/document.evaluate">document.evaluate</a>
</dt><dd> Evaluates an XPath expression.
</dd></dl>
<dl><dt> <a href="en/DOM/document.execCommand">document.execCommand</a>*
</dt><dd> Executes a <a href="en/Midas">Midas</a> command.
</dd></dl>
<dl><dt> <a href="en/DOM/document.getElementById">document.getElementById</a>
</dt><dd> Returns an object reference to the identified element.
</dd></dl>
<dl><dt> <a href="en/DOM/document.getElementsByName">document.getElementsByName</a>
</dt><dd> Returns a list of elements with the given name.
</dd></dl>
<dl><dt> <a href="en/DOM/document.getElementsByTagName">document.getElementsByTagName</a>
</dt><dd> Returns a list of elements with the given tag name.
</dd></dl>
<dl><dt> <a href="en/DOM/document.getElementsByTagNameNS">document.getElementsByTagNameNS</a>
</dt><dd> Returns a list of elements with the given tag name and namespace.
</dd></dl>
<dl><dt> <a href="en/DOM/document.importNode">document.importNode</a>
</dt><dd> Returns a clone of a node from an external document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.loadOverlay">document.loadOverlay</a>
</dt><dd> Loads a <a href="en/XUL_Overlays"> XUL overlay</a> dynamically. This only works in XUL documents.
</dd></dl>
<dl><dt> <a href="en/DOM/document.open">document.open</a>*
</dt><dd> Opens a document stream for writing.
</dd></dl>
<dl><dt> <a href="en/DOM/document.queryCommandEnabled">document.queryCommandEnabled</a>*
</dt><dd> Returns true if the <a href="en/Midas">Midas</a> command can be executed on the current range.
</dd></dl>
<dl><dt> <a href="en/DOM/document.queryCommandIndeterm">document.queryCommandIndeterm</a>*
</dt><dd> Returns true if the <a href="en/Midas">Midas</a> command is in a indeterminate state on the current range.
</dd></dl>
<dl><dt> <a href="en/DOM/document.queryCommandState">document.queryCommandState</a>*
</dt><dd> Returns true if the <a href="en/Midas">Midas</a> command has been executed on the current range.
</dd></dl>
<dl><dt> <a href="en/DOM/document.queryCommandValue">document.queryCommandValue</a>*
</dt><dd> Returns the current value of the current range for <a href="en/Midas">Midas</a> command.
</dd></dl>
<dl><dt> <a href="en/DOM/document.write">document.write</a>*
</dt><dd> Writes text to a document.
</dd></dl>
<dl><dt> <a href="en/DOM/document.writeln">document.writeln</a>*
</dt><dd> Write a line of text to a document.
</dd></dl>
{{ wiki.languages( { "fr": "fr/DOM/document", "ja": "ja/DOM/document", "pl": "pl/DOM/document" } ) }}
Revert to this revision