Revision 10655 of Document

  • Revision slug: DOM/document
  • Revision title: document
  • Revision id: 10655
  • Created:
  • Creator: Marcoos
  • Is current revision? No
  • Comment 15 words added

Revision Content

{{ DomRef() }}

Each web page loaded in the browser has its own document object. This object serves as an entry point to the web page's content (the DOM tree, including elements such as {{ HTMLElement("body") }} and {{ HTMLElement("table") }}) and provides functionality global to the document (such as obtaining the page's URL and creating new elements in the document).

A document object can be obtained from various APIs:

Depending on the kind of the document (e.g. HTML or XML) different APIs may be available on the document object. This theoretical availability of APIs is usually described in terms of implementing interfaces defined in the relevant W3C DOM specifications:

  • All document objects implement the DOM Core Document and Node interfaces, meaning that the "core" properties and methods are available for all kinds of documents.
  • In addition to the generalized DOM Core document interface, HTML documents also implement the HTMLDocument interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor).
  • XUL documents (available to Mozilla add-on and application developers) implement their own additions to the core Document functionality.

Methods or properties listed here that are part of a more specialized interface have an asterisk (*) next to them and have additional information in the  Availability column.

Note that some APIs listed below are not available in all browsers for various reasons:

  • Obsolete: on its way of being removed from supporting browsers.
  • Non-standard: either an experimental feature not (yet?) agreed upon by all vendors, or a feature targeted specifically at the code running in a specific browser (e.g. Mozilla has a few DOM APIs created for its add-ons and application development).
  • Part of a completed or an emerging standard, but not (yet?) implemented in all browsers or implemented in the newest versions of the browsers.

Detailed browser compatibility tables are located at the pages describing each property or method.

Properties

Name Description Return Type Availability
document.activeElement Returns the currently focused element Element All
document.alinkColor*{{ Deprecated_inline() }} Returns or sets the color of active links in the document body. String HTML
document.all* {{ Deprecated_inline() }}     HTML
document.anchors* Returns a list of all of the anchors in the document. HTMLCollection HTML
document.applets*{{ Deprecated_inline() }} Returns an ordered list of the applets within a document. HTMLCollection HTML
document.async Used with document.load to indicate an asynchronous request. n/a All
Node.attributes Returns a collection of attributes of the given element NamedNodeMap All
Node.baseURI Gets the base URI for the document String All
document.baseURIObject {{ gecko_minversion_inline("1.9") }} {{ non-standard_inline() }} (Mozilla add-ons only!) Returns an {{ Interface("nsIURI") }} object representing the base URI for the document. {{ Interface("nsIURI") }} All (with UniversalXPConnect privileges)
document.bgColor*{{ Deprecated_inline() }} Gets/sets the background color of the current document. String HTML
document.body* Returns the BODY node of the current document. HTMLBodyElement HTML
document.characterSet Returns the character set being used by the document. String All
Node.childNodes returns a collection of child nodes of the given node NodeList All
document.compatMode* Indicates whether the document is rendered in Quirks or Strict mode. String HTML
document.contentType {{ non-standard_inline() }} Returns the Content-Type from the MIME Header of the current document. String All
document.cookie* Returns a semicolon-separated list of the cookies for that document or sets a single cookie. String HTML
{{ domxref("document.currentScript") }}* {{ gecko_minversion_inline("2.0") }} {{ non-standard_inline() }} Returns the {{ HTMLElement("script") }} element that is currently executing. {{ domxref("Element") }} HTML, XUL
document.defaultView Returns a reference to the window object. Window All
document.designMode* Gets/sets WYSYWIG editing capability of Midas. It can only be used for HTML documents. String HTML
document.dir Gets/sets directionality (rtl/ltr) of the document String ?
document.doctype Returns the Document Type Definition (DTD) of the current document. DocumentType All
Name Description Return Type Availability
document.documentElement Returns the Element that is a direct child of document. For HTML documents, this is normally the HTML element. Element All
document.documentURI Returns the document location. String All
document.documentURIObject {{ gecko_minversion_inline("1.9") }} {{ non-standard_inline() }} (Mozilla add-ons only!) Returns the {{ Interface("nsIURI") }} object representing the URI of the document. This property only has special meaning in privileged JavaScript code (with UniversalXPConnect privileges). nsIURI All (with UniversalXPConnect privileges)
document.domain* Returns the domain of the current document. String HTML
document.embeds* Returns a list of the embedded OBJECTS within the current document. HTMLCollection HTML
document.fgColor*{{ Deprecated_inline() }} Gets/sets the foreground color, or text color, of the current document. String HTML
document.fileSize* {{ non-standard_inline() }} {{ unimplemented_inline() }}

(IE-only!) Returns size in bytes of the document. See MSDN.

Number HTML
Node.firstChild Returns the first node in the list of direct children of the document, typically (but not limited to) the DocumentType (same as document.doctype) or the root element (document.documentElement) Node All
document.forms* Returns a list of the FORM elements within the current document. HTMLCollection HTML
document.head* Returns the HEAD node of the current document. HTMLHeadElement HTML
document.height {{ obsolete_inline("6") }} Gets/sets the height of the current document. Number ?
document.images* Returns a list of the images in the current document. HTMLCollection HTML
document.implementation Returns the DOM implementation associated with the current document. DOMImplementation All
document.inputEncoding Returns the encoding used when the document was parsed. String All
Node.lastChild Returns the last child of a node Node All
document.lastModified Returns the date on which the document was last modified. String All
document.lastStyleSheetSet {{ gecko_minversion_inline("1.9") }} Returns the name of the style sheet set that was last enabled. Has the value null until the style sheet is changed by setting the value of selectedStyleSheetSet. String All
document.linkColor*{{ Deprecated_inline() }} Gets/sets the color of hyperlinks in the document. String HTML
Name Description Return Type Availability
document.links* Returns a list of all the hyperlinks in the document. HTMLCollection HTML
Node.localName Returns the local part of the qualified name of this node (null for a document) String All
document.location Returns the URI of the current document. Location All
{{ domxref("document.mozSyntheticDocument") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("8.0") }} true if this document is synthetic, such as a standalone image, video, audio file, or the like. Boolean All
{{ domxref("document.mozFullScreen") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("9.0") }} true when the document is in full-screen mode. Boolean All
{{ domxref("document.mozFullScreenElement") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("9.0") }} The element that's currently in full screen mode for this document. {{ domxref("Element") }} All
{{ domxref("document.mozFullScreenEnabled") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("9.0") }} true if calling {{ domxref("element.mozRequestFullscreen()") }} would succeed in the curent document. Boolean All
Node.namespaceURI Returns the XML namespace of the current document.   All
Node.nextSibling Returns the node immediately following the specified one in its parent's childNodes list, or null if the specified node is the last node in that list (null for documents)   All
Node.nodeName Returns the node's name (#document for document) String All
Node.nodeType Returns a node type constant (9 for document) Number All
Node.nodeValue Returns the node's value (null for document)   All
Node.nodePrincipal {{ non-standard_inline() }} {{ gecko_minversion_inline("1.9") }} (Mozilla add-ons only!) Returns the nsIPrincipal object representing current security context of the document. {{ Interface("nsIPrincipal") }} All (with UniversalXPConnect privileges)
Node.ownerDocument Returns the top-level document object for this node (null if already is the document).   All
Node.parentNode Returns the parent of the specified node in the DOM tree (null for document)   All
document.plugins Returns a list of the available plugins. {{ domxref("HTMLCollection") }} HTML
document.popupNode* Returns the node upon which a popup was invoked (XUL documents only). Node XUL
document.preferredStyleSheetSet Returns the preferred style sheet set as specified by the page author. String All
Node.prefix Returns the namespace prefix of the specified node, or null if no prefix is specified   All
Node.previousSibling Returns the node immediately preceding the specified one in its parent's childNodes list, null if the specified node is the first in that list (null for document)   All
document.readyState {{ gecko_minversion_inline("1.9.2") }} Returns loading status of the document String All
document.referrer* Returns the URI of the page that linked to this page. String All
{{ domxref("document.scripts") }} Returns all the {{ HTMLElement("script") }} elements on the document. {{ domxref("HTMLCollection") }} HTML
document.selectedStyleSheetSet {{ gecko_minversion_inline("1.9") }} Returns which style sheet set is currently in use. String All
document.styleSheets Returns a list of the stylesheet objects on the current document. StyleSheetList All
document.styleSheetSets {{ gecko_minversion_inline("1.9") }} Returns a list of the style sheet sets available on the document. StringList All
Node.textContent Returns null (returns other values for other nodes). Null All
document.title* Returns the title of the current document. String HTML, XUL
document.tooltipNode* Returns the node which is the target of the current tooltip. Node Object XUL
document.URL* Returns a string containing the URL of the current document. String HTML
document.vlinkColor* {{ Deprecated_inline() }} Gets/sets the color of visited hyperlinks. String HTML
document.width {{ obsolete_inline("6") }} Returns the width of the current document. Number ?
document.xmlEncoding {{ Deprecated_inline() }} Returns the encoding as determined by the XML declaration.
Firefox 10 and later don't implement it anymore.
String DOM 3 Removed in DOM 4
document.xmlStandalone {{ obsolete_inline("10.0") }}

Returns true if the XML declaration specifies the document is standalone (e.g., An external part of the DTD affects the document's content), else false.

Boolean DOM 3 Removed in DOM 4
document.xmlVersion {{ obsolete_inline("10.0") }}

Returns the version number as specified in the XML declaration or "1.0" if the declaration is absent.

String DOM 3 Removed in DOM 4

Methods

{{ domxref("element.addEventListener") }}
Adds an event listener to the document.
{{ domxref("document.adoptNode") }} {{ Fx_minversion_inline("3") }}
Adopt node from an external document
{{ domxref("Node.appendChild") }}
Adds a node to the end of the list of children of a specified parent node.
{{ domxref("document.captureEvents") }}
{{ domxref("document.clear") }}* {{ Deprecated_inline() }}
In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.
{{ domxref("Node.cloneNode") }}
Makes a copy of a node or document
{{ domxref("document.close") }}*
Closes a document stream for writing.
{{ domxref("Node.compareDocumentPosition") }}
Compares the position of the current node against another node in any other document.
{{ domxref("document.createAttribute") }}
Creates a new attribute node and returns it.
{{ domxref("document.createAttributeNS") }}
Creates a new attribute node in a given namespace and returns it.
{{ domxref("document.createCDATASection") }}
Creates a new CDATA node and returns it.
{{ domxref("document.createComment") }}
Creates a new comment node and returns it.
{{ domxref("document.createDocumentFragment") }}
Creates a new document fragment.
{{ domxref("document.createElement") }}
Creates a new element with the given tag name.
{{ domxref("document.createElementNS") }}
Creates a new element with the given tag name and namespace URI.
{{ domxref("document.createEntityReference") }} {{ obsolete_inline("7.0") }}
Creates a new entity reference object and returns it.
{{ domxref("document.createEvent") }}
Creates an event.
{{ domxref("document.createExpression") }}
Compiles an XPathExpression which can then be used for (repeated) evaluations.
{{ domxref("document.createNSResolver") }}
Creates an XPathNSResolver.
{{ domxref("document.createProcessingInstruction") }}
Creates a new processing instruction element and returns it.
{{ domxref("document.createRange") }}
Creates a Range object.
{{ domxref("document.createTextNode") }}
Creates a text node.
{{ domxref("document.createTreeWalker") }}
Creates a {{ domxref("treeWalker") }} object.
{{ domxref("document.elementFromPoint") }} {{ Fx_minversion_inline("3") }}
Returns the element visible at the specified coordinates.
{{ domxref("document.enableStyleSheetsForSet()") }} {{ gecko_minversion_inline("1.9") }}
Enables the style sheets for the specified style sheet set.
{{ domxref("document.evaluate") }}
Evaluates an XPath expression.
document.execCommand*
Executes a Midas command.
{{ domxref("document.execCommandShowHelp") }}
{{ domxref("document.getBoxObjectFor") }}
{{ domxref("document.getElementById") }}
Returns an object reference to the identified element.
{{ domxref("document.getElementsByClassName") }} {{ Fx_minversion_inline("3") }}
Returns a list of elements with the given class name.
{{ domxref("document.getElementsByName") }}*
Returns a list of elements with the given name.
{{ domxref("document.getElementsByTagName") }}
Returns a list of elements with the given tag name.
{{ domxref("document.getElementsByTagNameNS") }}
Returns a list of elements with the given tag name and namespace.
{{ domxref("Node.getFeature") }}
{{ domxref("document.getSelection") }}
Returns a {{ domxref("Selection") }} object related to text selected in the document.
{{ domxref("Node.getUserData") }}
Returns any data previously set on the node via setUserData() by key
{{ domxref("Node.hasAttributes") }}
Indicates whether the node possesses attributes
{{ domxref("Node.hasChildNodes") }}
Returns a Boolean value indicating whether the current element has child nodes or not.
{{ domxref("document.hasFocus") }}
Returns true if the focus is currently located anywhere inside the specified document.
{{ domxref("document.importNode") }}
Returns a clone of a node from an external document
{{ domxref("Node.insertBefore") }}
Inserts the specified node before a reference node as a child of the current node.
{{ domxref("Node.isDefaultNamespace") }}
Returns true if the namespace is the default namespace on the given node
{{ domxref("Node.isEqualNode") }}
Indicates whether the node is equal to the given node
{{ domxref("Node.isSameNode") }}
Indicates whether the node is the same as the given node
{{ domxref("Node.isSupported") }}
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node or document
{{ domxref("document.load") }}
Load an XML document
{{ domxref("document.loadOverlay") }}* {{ Fx_minversion_inline("1.5") }}
Loads a XUL overlay dynamically. This only works in XUL documents.
{{ domxref("Node.lookupNamespaceURI") }}
Returns the namespaceURI associated with a given prefix on the given node object
{{ domxref("Node.lookupPrefix") }}
Returns the prefix for a given namespaceURI on the given node if present
{{ domxref("Node.normalize") }}
Normalizes the node or document
{{ domxref("document.normalizeDocument") }} {{ obsolete_inline("7.0") }}
Replaces entities, normalizes text nodes, etc.
{{ domxref("document.open") }}*
Opens a document stream for writing.
{{ domxref("document.queryCommandEnabled") }}*
Returns true if the Midas command can be executed on the current range.
{{ domxref("document.queryCommandIndeterm") }}*
Returns true if the Midas command is in a indeterminate state on the current range.
{{ domxref("document.queryCommandState") }}*
Returns true if the Midas command has been executed on the current range.
{{ domxref("document.queryCommandSupported") }}
{{ domxref("document.queryCommandText") }}
{{ domxref("document.queryCommandValue") }}*
Returns the current value of the current range for Midas command. As of Firefox 2.0.0.2, queryCommandValue will return an empty string when a command value has not been explicitly set.
{{ domxref("document.querySelector") }} {{ gecko_minversion_inline("1.9.1") }}
Returns the first Element node within the document, in document order, that matches the specified selectors.
{{ domxref("document.querySelectorAll") }} {{ gecko_minversion_inline("1.9.1") }}
Returns a list of all the Element nodes within the document that match the specified selectors.
{{ domxref("document.releaseCapture()") }} {{ gecko_minversion_inline("2.0") }}
Releases the current mouse capture if it's on an element in this document.
{{ domxref("document.releaseEvents") }}
{{ domxref("Node.removeChild") }}
Removes a child node from the DOM
{{ domxref("document.removeEventListener") }}
Removes an event listener from the document
{{ domxref("Node.replaceChild") }}
Replaces one child node of the specified node with another
{{ domxref("document.routeEvent") }}
{{ domxref("document.mozSetImageElement") }} {{ gecko_minversion_inline("2.0") }}
Allows you to change the element being used as the background image for a specified element ID.
{{ domxref("Node.setUserData") }}
Attaches arbitrary data to a node, along with a user-defined key and an optional handler to be triggered upon events such as cloning of the node upon which the data was attached
{{ domxref("document.write") }}*
Writes text to a document.
{{ domxref("document.writeln") }}*
Write a line of text to a document.

Event handlers

Firefox 3 introduces two new events: "online" and "offline". These two events are fired on the {{ HTMLElement("body") }} of each page when the browser switches between online and offline mode. Additionally, the events bubble up from {{ domxref("document.body") }}, to {{ domxref("Document") }}, ending at {{ domxref("Window") }}. Both events are non-cancelable (you can't prevent the user from coming online, or going offline). For more details see Online and offline events.

Also, see the DOM event reference for a list of available events.

{{ domxref("document.ononline") }} {{ Fx_minversion_inline("3") }}
Returns the event handling code for the online event.
{{ domxref("document.onoffline") }} {{ Fx_minversion_inline("3") }}
Returns the event handling code for the offline event.
{{ domxref("document.onreadystatechange") }} {{ gecko_minversion_inline("1.9.2") }}
Returns the event handling code for the readystatechange event.

{{ gecko_callout_heading("9.0") }}

Starting in Gecko 9.0 {{ geckoRelease("9.0") }}, you can now use the syntax if ("onabort" in document) to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. See DOM event handlers for details.

Security notes

{{ Fx_minversion_note("3") }}

When a new document is created, it initially gets "about:blank" loaded into it. In versions of Firefox prior to Firefox 3, "about:blank" documents didn't get the parent principal. This means that access to their contents was not restricted. While this doesn't seem like a significant issue, it can be if code proceeds to add content to the document using DOM methods and properties such as {{ domxref("Node.appendChild") }} and so forth, because that content would not be protected from unauthorized access.

Firefox 3 updates Gecko so that new documents inherit the parent principal. This improves security both for iframes and documents that are in the process of being loaded, as well as for documents constructed programmatically.

Specification

{{ languages( { "fr": "fr/DOM/document", "ja": "ja/DOM/document", "pl": "pl/DOM/document", "es": "es/DOM/document", "zh-cn": "cn/DOM/document", "de" : "de/DOM/document" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<p>Each web page loaded in the browser has its own <strong>document</strong> object. This object serves as an entry point to the web page's content (the <a href="/en/Using_the_W3C_DOM_Level_1_Core" title="en/Using_the_W3C_DOM_Level_1_Core">DOM tree</a>, including elements such as {{ HTMLElement("body") }} and {{ HTMLElement("table") }}) and provides functionality global to the document (such as obtaining the page's URL and creating new elements in the document).</p>
<p>A document object can be obtained from various APIs:</p>
<ul> <li>Most commonly, you work with the document the script is running in by using <code>document</code> in document's <a href="/En/HTML/Element/Script" title="en/HTML/Element/Script">scripts</a>. (The same document can also be referred to as <a href="/en/DOM/window.document" title="window.document"><code>window.document</code></a>.)</li> <li>The document of an iframe via the iframe's <code><a href="/en/DOM/HTMLIFrameElement#Properties" title="en/DOM/HTMLIFrameElement#Properties">contentDocument</a></code> property.</li> <li>The <a href="/en/nsIXMLHttpRequest#Attributes" title="en/XMLHttpRequest#Attributes"><code>responseXML</code> of an <code>XMLHttpRequest</code> object</a>.</li> <li>The document, that given node or element belongs to, can be retrieved using the node's <code><a href="/En/DOM/Node.ownerDocument" title="en/DOM/Node.ownerDocument">ownerDocument</a></code> property.</li> <li>...and more.</li>
</ul>
<p>Depending on the kind of the document (e.g. <a href="/en/HTML" title="en/HTML">HTML</a> or <a href="/en/XML" title="en/XML">XML</a>) different APIs may be available on the document object. This theoretical availability of APIs is usually described in terms of <em>implementing interfaces</em> defined in the relevant W3C DOM specifications:</p>
<ul> <li>All document objects implement the DOM Core <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document"><code>Document</code></a> and <code><a href="/en/DOM/Node" title="en/DOM/Node">Node</a></code> interfaces, meaning that the "core" properties and methods are available for all kinds of documents.</li> <li>In addition to the generalized DOM Core document interface, HTML documents also implement the <code><a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268">HTMLDocument</a></code> interface, which is a more specialized interface for dealing with HTML documents (e.g., <a href="/en/DOM/document.cookie" title="en/DOM/document.cookie">document.cookie</a>, <a href="/en/DOM/document.alinkColor" title="en/DOM/document.alinkColor">document.alinkColor</a>).</li> <li><a href="/en/XUL" title="en/XUL">XUL</a> documents (available to Mozilla add-on and application developers) implement their own additions to the core Document functionality.</li>
</ul>
<p>Methods or properties listed here that are part of a more specialized interface have an asterisk (*) next to them and have additional information in the  Availability column.</p>
<p>Note that some APIs listed below are not available in all browsers for various reasons:</p>
<ul> <li><strong>Obsolete</strong>: on its way of being removed from supporting browsers.</li> <li><strong>Non-standard</strong>: either an experimental feature not (yet?) agreed upon by all vendors, or a feature targeted specifically at the code running in a specific browser (e.g. Mozilla has a few DOM APIs created for its add-ons and application development).</li> <li>Part of a completed or an emerging standard, but not (yet?) implemented in all browsers or implemented in the newest versions of the browsers.</li>
</ul>
<p>Detailed browser compatibility tables are located at the pages describing each property or method.</p>
<h3 name="Properties">Properties</h3>
<table class="standard-table"> <tbody> <tr> <th>Name</th> <th>Description</th> <th>Return Type</th> <th>Availability</th> </tr> <tr> <td><code><a href="/en/DOM/document.activeElement" title="en/DOM/document.activeElement">document.activeElement</a></code></td> <td>Returns the currently focused element</td> <td><a href="/en/DOM/element" title="en/DOM/element">Element</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.alinkColor" title="en/DOM/document.alinkColor">document.alinkColor</a></code>*{{ Deprecated_inline() }}</td> <td>Returns or sets the color of active links in the document body.</td> <td><a href="/En/Core_JavaScript_1.5_Reference/Global_Objects/String" title="en/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/En/DOM/document.all" title="En/DOM/document.all">document.all</a></code>* {{ Deprecated_inline() }}</td> <td> </td> <td> </td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.anchors" title="en/DOM/document.anchors">document.anchors</a></code>*</td> <td>Returns a list of all of the anchors in the document.</td> <td><a href="/en/DOM/HTMLCollection" title="en/DOM/HTMLCollection">HTMLCollection</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.applets" title="en/DOM/document.applets">document.applets</a></code>*{{ Deprecated_inline() }}</td> <td>Returns an ordered list of the applets within a document.</td> <td><a href="/en/DOM/HTMLCollection" title="en/DOM/HTMLCollection">HTMLCollection</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.async" title="en/DOM/document.async">document.async</a></code></td> <td>Used with <a href="/en/DOM/document.load" title="en/DOM/document.load">document.load</a> to indicate an asynchronous request.</td> <td>n/a</td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.attributes" title="En/DOM/Node.attributes">Node.attributes</a></code></td> <td>Returns a collection of attributes of the given element</td> <td><a href="/En/DOM/NamedNodeMap" title="En/DOM/NamedNodeMap">NamedNodeMap</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/Node.baseURI" title="en/DOM/Node.baseURI">Node.baseURI</a></code></td> <td>Gets the base URI for the document</td> <td><a href="/En/Core_JavaScript_1.5_Reference/Global_Objects/String" title="en/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.baseURIObject" title="en/DOM/document.baseURIObject">document.baseURIObject</a></code> {{ gecko_minversion_inline("1.9") }} {{ non-standard_inline() }}</td> <td>(<span style="font-weight: bold;">Mozilla</span><strong> add-ons only!</strong>) Returns an {{ Interface("nsIURI") }} object representing the base URI for the document.</td> <td>{{ Interface("nsIURI") }}</td> <td>All <small>(with UniversalXPConnect privileges)</small></td> </tr> <tr> <td><code><a href="/en/DOM/document.bgColor" title="en/DOM/document.bgColor">document.bgColor</a></code>*{{ Deprecated_inline() }}</td> <td>Gets/sets the background color of the current document.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.body" title="en/DOM/document.body">document.body</a></code>*</td> <td>Returns the BODY node of the current document.</td> <td><a href="/en/HTML/Element/body" title="en/DOM/HTMLBodyElement">HTMLBodyElement</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.characterSet" title="en/DOM/document.characterSet">document.characterSet</a></code></td> <td>Returns the character set being used by the document.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.childNodes" title="En/DOM/Node.childNodes">Node.childNodes</a></code></td> <td>returns a <em>collection</em> of child nodes of the given node</td> <td><a href="/En/DOM/NodeList" title="En/DOM/NodeList">NodeList</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.compatMode" title="en/DOM/document.compatMode">document.compatMode</a></code>*</td> <td>Indicates whether the document is rendered in Quirks or Strict mode.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.contentType" title="en/DOM/document.contentType">document.contentType</a></code> {{ non-standard_inline() }}</td> <td>Returns the Content-Type from the MIME Header of the current document.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.cookie" title="en/DOM/document.cookie">document.cookie</a></code>*</td> <td>Returns a semicolon-separated list of the cookies for that document or sets a single cookie.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td>{{ domxref("document.currentScript") }}* {{ gecko_minversion_inline("2.0") }} {{ non-standard_inline() }}</td> <td>Returns the {{ HTMLElement("script") }} element that is currently executing.</td> <td>{{ domxref("Element") }}</td> <td>HTML, XUL</td> </tr> <tr> <td><code><a href="/en/DOM/document.defaultView" title="en/DOM/document.defaultView">document.defaultView</a></code></td> <td>Returns a reference to the window object.</td> <td><a href="/en/DOM/window" title="en/DOM/window">Window</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.designMode" title="en/DOM/document.designMode">document.designMode</a></code>*</td> <td>Gets/sets WYSYWIG editing capability of <a href="/en/Midas" title="en/Midas">Midas</a>. It can only be used for HTML documents.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><a class="internal" href="/En/DOM/Document.dir" title="En/DOM/document.dir"><code>document.dir</code></a></td> <td>Gets/sets directionality (rtl/ltr) of the document</td> <td>String</td> <td>?</td> </tr> <tr> <td><code><a href="/en/DOM/document.doctype" title="en/DOM/document.doctype">document.doctype</a></code></td> <td>Returns the Document Type Definition (DTD) of the current document.</td> <td><a href="/En/DOM/DocumentType" title="En/DOM/DocumentType">DocumentType</a></td> <td>All</td> </tr> <tr> <th>Name</th> <th class="header">Description</th> <th class="header">Return Type</th> <th class="header">Availability</th> </tr> <tr> <td><code><a href="/en/DOM/document.documentElement" title="en/DOM/document.documentElement">document.documentElement</a></code></td> <td>Returns the Element that is a direct child of document. For HTML documents, this is normally the HTML element.</td> <td><a href="/en/DOM/element" title="en/DOM/element">Element</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.documentURI" title="en/DOM/document.documentURI">document.documentURI</a></code></td> <td>Returns the document location.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.documentURIObject" title="en/DOM/document.documentURIObject">document.documentURIObject</a></code> {{ gecko_minversion_inline("1.9") }} {{ non-standard_inline() }}</td> <td>(<strong>Mozilla add-ons only!</strong>) Returns the {{ Interface("nsIURI") }} object representing the URI of the document. This property only has special meaning in privileged JavaScript code (with UniversalXPConnect privileges).</td> <td><a href="/en/XPCOM_Interface_Reference/nsIURI" title="en/nsIURI">nsIURI</a></td> <td>All <small>(with UniversalXPConnect privileges)</small></td> </tr> <tr> <td><code><a href="/en/DOM/document.domain" title="en/DOM/document.domain">document.domain</a></code>*</td> <td>Returns the domain of the current document.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.embeds" title="en/DOM/document.embeds">document.embeds</a></code>*</td> <td>Returns a list of the embedded OBJECTS within the current document.</td> <td><a href="/en/DOM/HTMLCollection" title="en/DOM/HTMLCollection">HTMLCollection</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.fgColor" title="en/DOM/document.fgColor">document.fgColor</a></code>*{{ Deprecated_inline() }}</td> <td>Gets/sets the foreground color, or text color, of the current document.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><code>document.fileSize</code>* {{ non-standard_inline() }} {{ unimplemented_inline() }}</td> <td> <p>(<strong>IE-only!</strong>) Returns size in bytes of the document. See <a class="external" href="http://msdn.microsoft.com/en-us/library/ms533752%28v=VS.85%29.aspx" title="http://msdn.microsoft.com/en-us/library/ms533752%28v=VS.85%29.aspx">MSDN</a>.</p> </td> <td>Number</td> <td>HTML</td> </tr> <tr> <td><code><a href="/En/DOM/Node.firstChild" title="en/DOM/Node.firstChild">Node.firstChild</a></code></td> <td>Returns the first node in the list of direct children of the document, typically (but not limited to) the <a href="/DocumentType" title="DocumentType">DocumentType</a> (same as <a href="/en/DOM/document.doctype" title="document.doctype">document.doctype</a>) or the root element (<a href="/en/DOM/document.documentElement" title="document.documentElement">document.documentElement</a>)</td> <td>Node</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.forms" title="en/DOM/document.forms">document.forms</a></code>*</td> <td>Returns a list of the FORM elements within the current document.</td> <td><a href="/en/DOM/HTMLCollection" title="en/DOM/HTMLCollection">HTMLCollection</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.head" title="en/DOM/document.head">document.head</a></code>*</td> <td>Returns the HEAD node of the current document.</td> <td><a href="/en/HTML/Element/body" title="en/DOM/HTMLHeadElement">HTMLHeadElement</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.height" title="en/DOM/document.height">document.height</a></code> {{ obsolete_inline("6") }}</td> <td>Gets/sets the height of the current document.</td> <td><a href="/En/Core_JavaScript_1.5_Reference/Global_Objects/Number" title="en/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></td> <td>?</td> </tr> <tr> <td><code><a href="/en/DOM/document.images" title="en/DOM/document.images">document.images</a></code>*</td> <td>Returns a list of the images in the current document.</td> <td><a href="/en/DOM/HTMLCollection" title="en/DOM/HTMLCollection">HTMLCollection</a></td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.implementation" title="en/DOM/document.implementation">document.implementation</a></code></td> <td>Returns the DOM implementation associated with the current document.</td> <td><a href="/En/DOM/DOMImplementation" title="en/DOM/DOMImplementation">DOMImplementation</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.inputEncoding" title="en/DOM/document.inputEncoding">document.inputEncoding</a></code></td> <td>Returns the encoding used when the document was parsed.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.lastChild" title="En/DOM/Node.lastChild">Node.lastChild</a></code></td> <td>Returns the last child of a node</td> <td><a href="/en/DOM/Node" title="en/DOM/Node">Node</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.lastModified" title="en/DOM/document.lastModified">document.lastModified</a></code></td> <td>Returns the date on which the document was last modified.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.lastStyleSheetSet" title="En/DOM/document.lastStyleSheetSet">document.lastStyleSheetSet</a></code> {{ gecko_minversion_inline("1.9") }}</td> <td>Returns the name of the style sheet set that was last enabled. Has the value <code>null</code> until the style sheet is changed by setting the value of <code>selectedStyleSheetSet</code>.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.linkColor" title="en/DOM/document.linkColor">document.linkColor</a></code>*{{ Deprecated_inline() }}</td> <td>Gets/sets the color of hyperlinks in the document.</td> <td>String</td> <td>HTML</td> </tr> <tr> <th>Name</th> <th class="header">Description</th> <th class="header">Return Type</th> <th class="header">Availability</th> </tr> <tr> <td><code><a href="/en/DOM/document.links" title="en/DOM/document.links">document.links</a></code>*</td> <td>Returns a list of all the hyperlinks in the document.</td> <td><a href="/en/DOM/HTMLCollection" title="en/DOM/HTMLCollection">HTMLCollection</a></td> <td>HTML</td> </tr> <tr> <td><a class="internal" href="/En/DOM/Node.localName" title="En/DOM/Node.localName"><code>Node.localName</code></a></td> <td>Returns the local part of the qualified name of this node (null for a document)</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.location" title="en/DOM/document.location">document.location</a></code></td> <td>Returns the URI of the current document.</td> <td><a href="/en/DOM/Location" title="en/DOM/Location">Location</a></td> <td>All</td> </tr> <tr> <td>{{ domxref("document.mozSyntheticDocument") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("8.0") }}</td> <td><code>true</code> if this document is synthetic, such as a standalone image, video, audio file, or the like.</td> <td>Boolean</td> <td>All</td> </tr> <tr> <td>{{ domxref("document.mozFullScreen") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("9.0") }}</td> <td><code>true</code> when the document is in <a href="/en/DOM/Using_full-screen_mode" title="en/DOM/Using full-screen mode">full-screen mode</a>.</td> <td>Boolean</td> <td>All</td> </tr> <tr> <td>{{ domxref("document.mozFullScreenElement") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("9.0") }}</td> <td>The element that's currently in full screen mode for this document.</td> <td>{{ domxref("Element") }}</td> <td>All</td> </tr> <tr> <td>{{ domxref("document.mozFullScreenEnabled") }} {{ non-standard_inline() }} {{ gecko_minversion_inline("9.0") }}</td> <td><code>true</code> if calling {{ domxref("element.mozRequestFullscreen()") }} would succeed in the curent document.</td> <td>Boolean</td> <td>All</td> </tr> <tr> <td><code><a href="/En/DOM/Node.namespaceURI" title="en/DOM/Node.namespaceURI">Node.namespaceURI</a></code></td> <td>Returns the XML namespace of the current document.</td> <td> </td> <td>All</td> </tr> <tr> <td><a class="internal" href="/En/DOM/Node.nextSibling" title="En/DOM/Node.nextSibling"><code>Node.nextSibling</code></a></td> <td>Returns the node immediately following the specified one in its parent's childNodes list, or null if the specified node is the last node in that list (null for documents)</td> <td> </td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.nodeName" title="En/DOM/Node.nodeName">Node.nodeName</a></code></td> <td>Returns the node's name (#document for document)</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.nodeType" title="En/DOM/Node.nodeType">Node.nodeType</a></code></td> <td>Returns a node type constant (9 for document)</td> <td>Number</td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.nodeValue" title="En/DOM/Node.nodeValue">Node.nodeValue</a></code></td> <td>Returns the node's value (null for document)</td> <td> </td> <td>All</td> </tr> <tr> <td><code><a href="/En/DOM/Node.nodePrincipal" title="en/DOM/Node.nodePrincipal">Node.nodePrincipal</a></code> {{ non-standard_inline() }} {{ gecko_minversion_inline("1.9") }}</td> <td>(<strong>Mozilla add-ons only!</strong>) Returns the <code>nsIPrincipal</code> object representing current security context of the document.</td> <td>{{ Interface("nsIPrincipal") }}</td> <td>All <small>(with UniversalXPConnect privileges)</small></td> </tr> <tr> <td><a class="internal" href="/En/DOM/Node.ownerDocument" title="En/DOM/Node.ownerDocument"><code>Node.ownerDocument</code></a></td> <td>Returns the top-level document object for this node (null if already is the document).</td> <td> </td> <td>All</td> </tr> <tr> <td><a class="internal" href="/En/DOM/Node.parentNode" title="En/DOM/Node.parentNode"><code>Node.parentNode</code></a></td> <td>Returns the parent of the specified node in the DOM tree (null for document)</td> <td> </td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.plugins" title="en/DOM/document.plugins">document.plugins</a></code></td> <td>Returns a list of the available plugins.</td> <td>{{ domxref("HTMLCollection") }}</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.popupNode" title="en/DOM/document.popupNode">document.popupNode</a></code>*</td> <td>Returns the node upon which a popup was invoked (XUL documents only).</td> <td><a href="/en/DOM/Node" title="en/DOM/Node">Node</a></td> <td>XUL</td> </tr> <tr> <td><code><a href="/en/DOM/document.preferredStyleSheetSet" title="En/DOM/document.preferredStyleSheetSet">document.preferredStyleSheetSet</a></code></td> <td>Returns the preferred style sheet set as specified by the page author.</td> <td>String</td> <td>All</td> </tr> <tr> <td><a class="internal" href="/En/DOM/Node.prefix" title="En/DOM/Node.prefix"><code>Node.prefix</code></a></td> <td>Returns the namespace prefix of the specified node, or <code>null</code> if no prefix is specified</td> <td> </td> <td>All</td> </tr> <tr> <td><code><a class="internal" href="/En/DOM/Node.previousSibling" title="En/DOM/Node.previousSibling">Node.previousSibling</a></code></td> <td>Returns the node immediately preceding the specified one in its parent's <a href="../../../../en/DOM/element.childNodes" rel="internal">childNodes</a> list, <code>null</code> if the specified node is the first in that list (null for document)</td> <td> </td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.readyState" title="en/DOM/document.readyState">document.readyState</a></code> {{ gecko_minversion_inline("1.9.2") }}</td> <td>Returns loading status of the document</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.referrer" title="en/DOM/document.referrer">document.referrer</a></code>*</td> <td>Returns the URI of the page that linked to this page.</td> <td>String</td> <td>All</td> </tr> <tr> <td>{{ domxref("document.scripts") }}</td> <td>Returns all the {{ HTMLElement("script") }} elements on the document.</td> <td>{{ domxref("HTMLCollection") }}</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.selectedStyleSheetSet" title="En/DOM/document.selectedStyleSheetSet">document.selectedStyleSheetSet</a></code> {{ gecko_minversion_inline("1.9") }}</td> <td>Returns which style sheet set is currently in use.</td> <td>String</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.styleSheets" title="en/DOM/document.styleSheets">document.styleSheets</a></code></td> <td>Returns a list of the stylesheet objects on the current document.</td> <td><a href="/en/DOM/StyleSheetList" title="en/DOM/StyleSheetList">StyleSheetList</a></td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.styleSheetSets" title="En/DOM/document.styleSheetSets">document.styleSheetSets</a></code> {{ gecko_minversion_inline("1.9") }}</td> <td>Returns a list of the style sheet sets available on the document.</td> <td>StringList</td> <td>All</td> </tr> <tr> <td><code><a href="/En/DOM/Node.textContent" title="en/DOM/Node.textContent">Node.textContent</a></code></td> <td>Returns null (returns other values for other nodes).</td> <td>Null</td> <td>All</td> </tr> <tr> <td><code><a href="/en/DOM/document.title" title="en/DOM/document.title">document.title</a></code>*</td> <td>Returns the title of the current document.</td> <td>String</td> <td>HTML, XUL</td> </tr> <tr> <td><code><a href="/en/DOM/document.tooltipNode" title="en/DOM/document.tooltipNode">document.tooltipNode</a></code>*</td> <td>Returns the node which is the target of the current tooltip.</td> <td>Node Object</td> <td>XUL</td> </tr> <tr> <td><code><a href="/en/DOM/document.URL" title="en/DOM/document.URL">document.URL</a></code>*</td> <td>Returns a string containing the URL of the current document.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.vlinkColor" title="en/DOM/document.vlinkColor">document.vlinkColor</a></code>* {{ Deprecated_inline() }}</td> <td>Gets/sets the color of visited hyperlinks.</td> <td>String</td> <td>HTML</td> </tr> <tr> <td><code><a href="/en/DOM/document.width" title="en/DOM/document.width">document.width</a></code> {{ obsolete_inline("6") }}</td> <td>Returns the width of the current document.</td> <td>Number</td> <td>?</td> </tr> <tr> <td><code><a href="/En/DOM/Document.xmlEncoding" title="en/DOM/document.xmlEncoding">document.xmlEncoding</a></code> {{ Deprecated_inline() }}</td> <td>Returns the encoding as determined by the XML declaration.<br> <div class="note">Firefox 10 and later don't implement it anymore.</div> </td> <td>String</td> <td>DOM 3 Removed in DOM 4</td> </tr> <tr> <td><code><a href="/en/DOM/document.xmlStandalone" title="en/DOM/document.xmlStandalone">document.xmlStandalone</a></code> {{ obsolete_inline("10.0") }}</td> <td> <p>Returns <code>true</code> if the XML declaration specifies the document is standalone (<em>e.g.,</em> An external part of the DTD affects the document's content), else <code>false</code>.</p> </td> <td><a href="/en/JavaScript/Reference/Global_Objects/Boolean" title="en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td> <td>DOM 3 Removed in DOM 4</td> </tr> <tr> <td><code><a href="/en/DOM/document.xmlVersion" title="en/DOM/document.xmlVersion">document.xmlVersion</a> </code>{{ obsolete_inline("10.0") }}</td> <td> <p>Returns the version number as specified in the XML declaration or <code>"1.0"</code> if the declaration is absent.</p> </td> <td>String</td> <td>DOM 3 Removed in DOM 4</td> </tr> </tbody>
</table>
<h3 name="Methods">Methods</h3>
<dl> <dt>{{ domxref("element.addEventListener") }}</dt> <dd>Adds an event listener to the document.</dd> <dt>{{ domxref("document.adoptNode") }} {{ Fx_minversion_inline("3") }}</dt> <dd>Adopt node from an external document</dd> <dt>{{ domxref("Node.appendChild") }}</dt> <dd>Adds a node to the end of the list of children of a specified parent node.</dd> <dt>{{ domxref("document.captureEvents") }}</dt> <dt>{{ domxref("document.clear") }}* {{ Deprecated_inline() }}</dt> <dd>In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.</dd> <dt>{{ domxref("Node.cloneNode") }}</dt> <dd>Makes a copy of a node or document</dd> <dt>{{ domxref("document.close") }}*</dt> <dd>Closes a document stream for writing.</dd> <dt>{{ domxref("Node.compareDocumentPosition") }}</dt> <dd>Compares the position of the current node against another node in any other document.</dd> <dt>{{ domxref("document.createAttribute") }}</dt> <dd>Creates a new attribute node and returns it.</dd> <dt>{{ domxref("document.createAttributeNS") }}</dt> <dd>Creates a new attribute node in a given namespace and returns it.</dd> <dt>{{ domxref("document.createCDATASection") }}</dt> <dd>Creates a new CDATA node and returns it.</dd> <dt>{{ domxref("document.createComment") }}</dt> <dd>Creates a new comment node and returns it.</dd> <dt>{{ domxref("document.createDocumentFragment") }}</dt> <dd>Creates a new document fragment.</dd> <dt>{{ domxref("document.createElement") }}</dt> <dd>Creates a new element with the given tag name.</dd> <dt>{{ domxref("document.createElementNS") }}</dt> <dd>Creates a new element with the given tag name and namespace URI.</dd> <dt>{{ domxref("document.createEntityReference") }} {{ obsolete_inline("7.0") }}</dt> <dd>Creates a new entity reference object and returns it.</dd> <dt>{{ domxref("document.createEvent") }}</dt> <dd>Creates an event.</dd> <dt>{{ domxref("document.createExpression") }}</dt> <dd>Compiles an <code><a href="/en/XPathExpression" title="en/XPathExpression">XPathExpression</a></code> which can then be used for (repeated) evaluations.</dd> <dt>{{ domxref("document.createNSResolver") }}</dt> <dd>Creates an XPathNSResolver.</dd> <dt>{{ domxref("document.createProcessingInstruction") }}</dt> <dd>Creates a new processing instruction element and returns it.</dd> <dt>{{ domxref("document.createRange") }}</dt> <dd>Creates a Range object.</dd> <dt>{{ domxref("document.createTextNode") }}</dt> <dd>Creates a text node.</dd> <dt>{{ domxref("document.createTreeWalker") }}</dt> <dd>Creates a {{ domxref("treeWalker") }} object.</dd> <dt>{{ domxref("document.elementFromPoint") }} {{ Fx_minversion_inline("3") }}</dt> <dd>Returns the element visible at the specified coordinates.</dd> <dt>{{ domxref("document.enableStyleSheetsForSet()") }} {{ gecko_minversion_inline("1.9") }}</dt> <dd>Enables the style sheets for the specified style sheet set.</dd> <dt>{{ domxref("document.evaluate") }}</dt> <dd>Evaluates an XPath expression.</dd> <dt><a href="/en/Rich-Text_Editing_in_Mozilla#Executing_Commands" title="en/Rich-Text_Editing_in_Mozilla#Executing_Commands">document.execCommand</a>*</dt> <dd>Executes a <a href="/en/Midas" title="en/Midas">Midas</a> command.</dd> <dt>{{ domxref("document.execCommandShowHelp") }}</dt> <dt>{{ domxref("document.getBoxObjectFor") }}</dt> <dt>{{ domxref("document.getElementById") }}</dt> <dd>Returns an object reference to the identified element.</dd> <dt>{{ domxref("document.getElementsByClassName") }} {{ Fx_minversion_inline("3") }}</dt> <dd>Returns a list of elements with the given class name.</dd> <dt>{{ domxref("document.getElementsByName") }}*</dt> <dd>Returns a list of elements with the given name.</dd> <dt>{{ domxref("document.getElementsByTagName") }}</dt> <dd>Returns a list of elements with the given tag name.</dd> <dt>{{ domxref("document.getElementsByTagNameNS") }}</dt> <dd>Returns a list of elements with the given tag name and namespace.</dd> <dt>{{ domxref("Node.getFeature") }}</dt> <dd> </dd><dt>{{ domxref("document.getSelection") }}</dt> <dd>Returns a {{ domxref("Selection") }} object related to text selected in the document.</dd> <dt>{{ domxref("Node.getUserData") }}</dt> <dd>Returns any data previously set on the node via setUserData() by key</dd> <dt>{{ domxref("Node.hasAttributes") }}</dt> <dd>Indicates whether the node possesses attributes</dd> <dt>{{ domxref("Node.hasChildNodes") }}</dt> <dd>Returns a Boolean value indicating whether the current element has child nodes or not.</dd> <dt>{{ domxref("document.hasFocus") }}</dt> <dd>Returns <code>true</code> if the focus is currently located anywhere inside the specified document.</dd> <dt>{{ domxref("document.importNode") }}</dt> <dd>Returns a clone of a node from an external document</dd> <dt>{{ domxref("Node.insertBefore") }}</dt> <dd>Inserts the specified node before a reference node as a child of the current node.</dd> <dt>{{ domxref("Node.isDefaultNamespace") }}</dt> <dd>Returns true if the namespace is the default namespace on the given node</dd> <dt>{{ domxref("Node.isEqualNode") }}</dt> <dd>Indicates whether the node is equal to the given node</dd> <dt>{{ domxref("Node.isSameNode") }}</dt> <dd>Indicates whether the node is the same as the given node</dd> <dt>{{ domxref("Node.isSupported") }}</dt> <dd>Tests whether the DOM implementation implements a specific feature and that feature is supported by this node or document</dd> <dt>{{ domxref("document.load") }}</dt> <dd>Load an XML document</dd> <dt>{{ domxref("document.loadOverlay") }}* {{ Fx_minversion_inline("1.5") }}</dt> <dd>Loads a <a href="/en/XUL_Overlays" title="en/XUL_Overlays">XUL overlay</a> dynamically. This only works in XUL documents.</dd> <dt>{{ domxref("Node.lookupNamespaceURI") }}</dt> <dd>Returns the namespaceURI associated with a given prefix on the given node object</dd> <dt>{{ domxref("Node.lookupPrefix") }}</dt> <dd>Returns the prefix for a given namespaceURI on the given node if present</dd> <dt>{{ domxref("Node.normalize") }}</dt> <dd>Normalizes the node or document</dd> <dt>{{ domxref("document.normalizeDocument") }} {{ obsolete_inline("7.0") }}</dt> <dd>Replaces entities, normalizes text nodes, etc.</dd> <dt>{{ domxref("document.open") }}*</dt> <dd>Opens a document stream for writing.</dd> <dt>{{ domxref("document.queryCommandEnabled") }}*</dt> <dd>Returns true if the <a href="/en/Midas" title="en/Midas">Midas</a> command can be executed on the current range.</dd> <dt>{{ domxref("document.queryCommandIndeterm") }}*</dt> <dd>Returns true if the <a href="/en/Midas" title="en/Midas">Midas</a> command is in a indeterminate state on the current range.</dd> <dt>{{ domxref("document.queryCommandState") }}*</dt> <dd>Returns true if the <a href="/en/Midas" title="en/Midas">Midas</a> command has been executed on the current range.</dd> <dt>{{ domxref("document.queryCommandSupported") }}</dt> <dd> </dd><dt>{{ domxref("document.queryCommandText") }}</dt> <dd> </dd><dt>{{ domxref("document.queryCommandValue") }}*</dt> <dd>Returns the current value of the current range for <a href="/en/Midas" title="en/Midas">Midas</a> command. As of Firefox 2.0.0.2, queryCommandValue will return an empty string when a command value has not been explicitly set.</dd> <dt>{{ domxref("document.querySelector") }} {{ gecko_minversion_inline("1.9.1") }}</dt> <dd>Returns the first Element node within the document, in document order, that matches the specified selectors.</dd> <dt>{{ domxref("document.querySelectorAll") }} {{ gecko_minversion_inline("1.9.1") }}</dt> <dd>Returns a list of all the Element nodes within the document that match the specified selectors.</dd> <dt>{{ domxref("document.releaseCapture()") }} {{ gecko_minversion_inline("2.0") }}</dt> <dd>Releases the current mouse capture if it's on an element in this document.</dd> <dt>{{ domxref("document.releaseEvents") }}</dt> <dd> </dd><dt>{{ domxref("Node.removeChild") }}</dt> <dd>Removes a child node from the DOM</dd> <dt>{{ domxref("document.removeEventListener") }}</dt> <dd>Removes an event listener from the document</dd> <dt>{{ domxref("Node.replaceChild") }}</dt> <dd>Replaces one child node of the specified node with another</dd> <dt>{{ domxref("document.routeEvent") }}</dt> <dd> </dd><dt>{{ domxref("document.mozSetImageElement") }} {{ gecko_minversion_inline("2.0") }}</dt> <dd>Allows you to change the element being used as the background image for a specified element ID.</dd> <dt>{{ domxref("Node.setUserData") }}</dt> <dd>Attaches arbitrary data to a node, along with a user-defined key and an optional handler to be triggered upon events such as cloning of the node upon which the data was attached</dd> <dt>{{ domxref("document.write") }}*</dt> <dd>Writes text to a document.</dd> <dt>{{ domxref("document.writeln") }}*</dt> <dd>Write a line of text to a document.</dd>
</dl>
<h3 name="Event_handlers">Event handlers</h3>
<p>Firefox 3 introduces two new events: "online" and "offline". These two events are fired on the {{ HTMLElement("body") }} of each page when the browser switches between online and offline mode. Additionally, the events bubble up from {{ domxref("document.body") }}, to {{ domxref("Document") }}, ending at {{ domxref("Window") }}. Both events are non-cancelable (you can't prevent the user from coming online, or going offline). For more details see <a href="/en/Online_and_offline_events" title="en/Online_and_offline_events">Online and offline events</a>.</p>
<p>Also, see the <a href="/en/DOM/DOM_event_reference" title="DOM event reference">DOM event reference</a> for a list of available events.</p>
<dl> <dt>{{ domxref("document.ononline") }} {{ Fx_minversion_inline("3") }}</dt> <dd>Returns the event handling code for the <code>online</code> event.</dd> <dt>{{ domxref("document.onoffline") }} {{ Fx_minversion_inline("3") }}</dt> <dd>Returns the event handling code for the <code>offline</code> event.</dd> <dt>{{ domxref("document.onreadystatechange") }} {{ gecko_minversion_inline("1.9.2") }}</dt> <dd>Returns the event handling code for the <code>readystatechange</code> event.</dd>
</dl>
<div class="geckoVersionNote" style="undefined"> <p>{{ gecko_callout_heading("9.0") }}</p> <p>Starting in Gecko 9.0 {{ geckoRelease("9.0") }}, you can now use the syntax <code>if ("onabort" in document)</code> to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. See <a href="/en/DOM/DOM_event_handlers" title="en/DOM/DOM event handlers">DOM event handlers</a> for details.</p>
</div>
<h3 name="Security_notes">Security notes</h3>
<p>{{ Fx_minversion_note("3") }}</p>
<p>When a new document is created, it initially gets "about:blank" loaded into it. In versions of Firefox prior to Firefox 3, "about:blank" documents didn't get the parent principal. This means that access to their contents was not restricted. While this doesn't seem like a significant issue, it can be if code proceeds to add content to the document using DOM methods and properties such as {{ domxref("Node.appendChild") }} and so forth, because that content would not be protected from unauthorized access.</p>
<p>Firefox 3 updates Gecko so that new documents inherit the parent principal. This improves security both for <code>iframe</code>s and documents that are in the process of being loaded, as well as for documents constructed programmatically.</p>
<h3 name="Specification">Specification</h3>
<ul> <li><a class=" external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document" rel="freelink">http://www.w3.org/TR/DOM-Level-3-Cor...tml#i-Document</a></li>
</ul>
<p>{{ languages( { "fr": "fr/DOM/document", "ja": "ja/DOM/document", "pl": "pl/DOM/document", "es": "es/DOM/document", "zh-cn": "cn/DOM/document", "de" : "de/DOM/document" } ) }}</p>
Revert to this revision