---
title: Document
slug: Web/API/Document
tags:
- API
- DOM
- Interface
- NeedsTranslation
- Reference
- TopicStub
translation_of: Web/API/Document
---
{{APIRef}}
The Document
interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. The DOM tree includes elements such as {{HTMLElement("body")}} and {{HTMLElement("table")}}, among many others. It provides functionality which is global to the document, such as obtaining the page's URL and creating new elements in the document.
{{inheritanceDiagram}}
The Document
interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g. HTML, XML, SVG, …), a larger API is available: HTML documents, served with the text/html
content type, also implement the {{domxref("HTMLDocument")}} interface, wherease SVG documents implement the {{domxref("SVGDocument")}} interface.
Properties
This interface also inherits from the {{domxref("Node")}} and {{domxref("EventTarget")}} interfaces.
- {{domxref("Document.all")}} {{Deprecated_inline}} {{non-standard_inline}}
- Provides access to all elements with an
id
. This is a legacy, non-standard interface and you should use the {{domxref("document.getElementById()")}} method instead.
- {{domxref("Document.async")}} {{Deprecated_inline}}
- Used with {{domxref("Document.load")}} to indicate an asynchronous request.
- {{domxref("Document.characterSet")}} {{readonlyinline}}
- Returns the character set being used by the document.
- {{domxref("Document.charset")}} {{readonlyinline}} {{Deprecated_inline}}
- Alias of {{domxref("Document.characterSet")}}. Use this property instead.
- {{domxref("Document.compatMode")}} {{readonlyinline}} {{experimental_inline}}
- Indicates whether the document is rendered in quirks or strict mode.
- {{domxref("Document.contentType")}} {{readonlyinline}} {{experimental_inline}}
- Returns the Content-Type from the MIME Header of the current document.
- {{domxref("Document.doctype")}} {{readonlyinline}}
- Returns the Document Type Definition (DTD) of the current document.
- {{domxref("Document.documentElement")}} {{readonlyinline}}
- Returns the {{domxref("Element")}} that is a direct child of the document. For HTML documents, this is normally the HTML element.
- {{domxref("Document.documentURI")}} {{readonlyinline}}
- Returns the document location as a string.
- {{domxref("Document.domConfig")}} {{Deprecated_inline}}
- Should return a {{domxref("DOMConfiguration")}} object.
- {{domxref("Document.fullscreen")}} {{obsolete_inline}}
true
when the document is in {{domxref("Using_full-screen_mode","full-screen mode")}}.
- {{domxref("Document.hidden")}} {{readonlyinline}}
- …
- {{domxref("Document.implementation")}} {{readonlyinline}}
- Returns the DOM implementation associated with the current document.
- {{domxref("Document.inputEncoding")}} {{readonlyinline}} {{Deprecated_inline}}
- Alias of {{domxref("Document.characterSet")}}. Use this property instead.
- {{domxref("Document.lastStyleSheetSet")}} {{readonlyinline}}
- 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 {{domxref("document.selectedStyleSheetSet","selectedStyleSheetSet")}}.
- {{domxref("Document.mozSyntheticDocument")}} {{non-standard_inline}} {{gecko_minversion_inline("8.0")}}
- Returns a {{jsxref("Boolean")}} that is
true
only if this document is synthetic, such as a standalone image, video, audio file, or the like.
- {{domxref("Document.mozFullScreenElement")}} {{readonlyinline}} {{non-standard_inline}} {{gecko_minversion_inline("9.0")}}
- The element that's currently in full screen mode for this document.
- {{domxref("Document.mozFullScreenEnabled")}} {{readonlyinline}} {{non-standard_inline}} {{gecko_minversion_inline("9.0")}}
true
if calling {{domxref("Element.mozRequestFullscreen()")}} would succeed in the curent document.
- {{domxref("Document.pointerLockElement")}} {{readonlyinline}} {{experimental_inline}}
- Returns the element set as the target for mouse events while the pointer is locked.
null
if lock is pending, pointer is unlocked, or if the target is in another document.
- {{domxref("Document.preferredStyleSheetSet")}} {{readonlyinline}}
- Returns the preferred style sheet set as specified by the page author.
- {{domxref("Document.scrollingElement")}} {{experimental_inline}} {{readonlyinline}}
- Returns a reference to the {{domxref("Element")}} that scrolls the document.
- {{domxref("Document.selectedStyleSheetSet")}}
- Returns which style sheet set is currently in use.
- {{domxref("Document.styleSheets")}} {{readonlyinline}}
- Returns a list of the style sheet objects on the current document.
- {{domxref("Document.styleSheetSets")}} {{readonlyinline}}
- Returns a list of the style sheet sets available on the document.
- {{domxref("Document.timeline")}} {{readonlyinline}}
- …
- {{domxref("Document.undoManager")}} {{readonlyinline}} {{experimental_inline}}
- …
- {{domxref("Document.URL")}} {{readonlyinline}}
- Returns ...
- {{domxref("Document.visibilityState")}} {{readonlyinline}}
- …
- {{domxref("Document.xmlEncoding")}} {{Deprecated_inline}}
- Returns the encoding as determined by the XML declaration.
- {{domxref("Document.xmlStandalone")}} {{obsolete_inline("10.0")}}
- Returns
true
if the XML declaration specifies the document to be standalone (e.g., An external part of the DTD affects the document's content), else false
.
- {{domxref("Document.xmlVersion")}} {{obsolete_inline("10.0")}}
- Returns the version number as specified in the XML declaration or
"1.0"
if the declaration is absent.
The Document
interface is extended with the {{domxref("ParentNode")}} interface:
{{page("/en-US/docs/Web/API/ParentNode","Properties")}}
Extension for HTML document
The Document
interface for HTML documents inherits from the {{domxref("HTMLDocument")}} interface or, since HTML5, is extended for such documents.
- {{domxref("Document.activeElement")}} {{readonlyinline}}
- Returns the currently focused element.
- {{domxref("Document.alinkColor")}} {{Deprecated_inline}}
- Returns or sets the color of active links in the document body.
- {{domxref("Document.anchors")}}
- Returns a list of all of the anchors in the document.
- {{domxref("Document.applets")}} {{Deprecated_inline}}
- Returns an ordered list of the applets within a document.
- {{domxref("Document.bgColor")}} {{Deprecated_inline}}
- Gets/sets the background color of the current document.
- {{domxref("Document.body")}}
- Returns the {{HTMLElement("body")}} element of the current document.
- {{domxref("Document.cookie")}}
- Returns a semicolon-separated list of the cookies for that document or sets a single cookie.
- {{domxref("Document.defaultView")}} {{readonlyinline}}
- Returns a reference to the window object.
- {{domxref("Document.designMode")}}
- Gets/sets the ability to edit the whole document.
- {{domxref("Document.dir")}} {{readonlyinline}}
- Gets/sets directionality (rtl/ltr) of the document.
- {{domxref("Document.domain")}} {{readonlyinline}}
- Returns the domain of the current document.
- {{domxref("Document.embeds")}} {{readonlyinline}}
- Returns a list of the embedded {{HTMLElement('embed')}} elements within the current document.
- {{domxref("document.fgColor")}} {{Deprecated_inline}}
- Gets/sets the foreground color, or text color, of the current document.
- {{domxref("Document.forms")}} {{readonlyinline}}
- Returns a list of the {{HTMLElement("form")}} elements within the current document.
- {{domxref("Document.head")}} {{readonlyinline}}
- Returns the {{HTMLElement("head")}} element of the current document.
- {{domxref("Document.height")}} {{non-standard_inline}} {{obsolete_inline}}
- Gets/sets the height of the current document.
- {{domxref("Document.images")}} {{readonlyinline}}
- Returns a list of the images in the current document.
- {{domxref("Document.lastModified")}} {{readonlyinline}}
- Returns the date on which the document was last modified.
- {{domxref("Document.linkColor")}} {{Deprecated_inline}}
- Gets/sets the color of hyperlinks in the document.
- {{domxref("Document.links")}} {{readonlyinline}}
- Returns a list of all the hyperlinks in the document.
- {{domxref("Document.location")}} {{readonlyinline}}
- Returns the URI of the current document.
- {{domxref("Document.plugins")}} {{readonlyinline}}
- Returns a list of the available plugins.
- {{domxref("Document.readyState")}} {{readonlyinline}} {{gecko_minversion_inline("1.9.2")}}
- Returns loading status of the document.
- {{domxref("Document.referrer")}} {{readonlyinline}}
- Returns the URI of the page that linked to this page.
- {{domxref("Document.scripts")}} {{readonlyinline}}
- Returns all the {{HTMLElement("script")}} elements on the document.
- {{domxref("Document.title")}}
- Sets or gets title of the current document.
- {{domxref("Document.URL")}} {{readonlyInline}}
- Returns the document location as a string.
- {{domxref("Document.vlinkColor")}} {{Deprecated_inline}}
- Gets/sets the color of visited hyperlinks.
- {{domxref("Document.width")}} {{non-standard_inline}} {{obsolete_inline}}
- Returns the width of the current document.
Event handlers
- {{domxref("GlobalEventHandlers.onabort")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("abort")}} event is raised.
- {{domxref("Document.onafterscriptexecute")}} {{non-standard_inline}}
- Represents the event handling code for the {{event("afterscriptexecute")}} event.
- {{domxref("Document.onbeforescriptexecute")}} {{non-standard_inline}}
- Represents the event handling code for the {{event("beforescriptexecute")}} event.
- {{domxref("GlobalEventHandlers.onblur")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("blur")}} event is raised.
- {{domxref("GlobalEventHandlers.oncancel")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("cancel")}} event is raised.
- {{domxref("GlobalEventHandlers.oncanplay")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("canplay")}} event is raised.
- {{domxref("GlobalEventHandlers.oncanplaythrough")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("canplaythrough")}} event is raised.
- {{domxref("GlobalEventHandlers.onchange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("change")}} event is raised.
- {{domxref("GlobalEventHandlers.onclick")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("click")}} event is raised.
- {{domxref("GlobalEventHandlers.onclose")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("close")}} event is raised.
- {{domxref("GlobalEventHandlers.oncontextmenu")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("contextmenu")}} event is raised.
- {{domxref("Document.oncopy")}} {{non-standard_inline}}
- Represents the event handling code for the {{event("copy")}} event.
- {{domxref("GlobalEventHandlers.oncuechange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("cuechange")}} event is raised.
- {{domxref("Document.oncut")}} {{non-standard_inline}}
- Represents the event handling code for the {{event("cut")}} event.
- {{domxref("GlobalEventHandlers.ondblclick")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dblclick")}} event is raised.
- {{domxref("GlobalEventHandlers.ondrag")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("drag")}} event is raised.
- {{domxref("GlobalEventHandlers.ondragend")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dragend")}} event is raised.
- {{domxref("GlobalEventHandlers.ondragenter")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dragenter")}} event is raised.
- {{domxref("GlobalEventHandlers.ondragexit")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dragexit")}} event is raised.
- {{domxref("GlobalEventHandlers.ondragleave")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dragleave")}} event is raised.
- {{domxref("GlobalEventHandlers.ondragover")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dragover")}} event is raised.
- {{domxref("GlobalEventHandlers.ondragstart")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("dragstart")}} event is raised.
- {{domxref("GlobalEventHandlers.ondrop")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("drop")}} event is raised.
- {{domxref("GlobalEventHandlers.ondurationchange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("durationchange")}} event is raised.
- {{domxref("GlobalEventHandlers.onemptied")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("emptied")}} event is raised.
- {{domxref("GlobalEventHandlers.onended")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("ended")}} event is raised.
- {{domxref("GlobalEventHandlers.onerror")}}
- Is an {{domxref("OnErrorEventHandler")}} representing the code to be called when the {{event("error")}} event is raised.
- {{domxref("GlobalEventHandlers.onfocus")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("focus")}} event is raised.
- {{domxref("Document.onfullscreenchange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("fullscreenchange")}} event is raised.
- {{domxref("Document.onfullscreenerror")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("fullscreenerror")}} event is raised.
- {{domxref("GlobalEventHandlers.oninput")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("input")}} event is raised.
- {{domxref("GlobalEventHandlers.oninvalid")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("invalid")}} event is raised.
- {{domxref("GlobalEventHandlers.onkeydown")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("keydown")}} event is raised.
- {{domxref("GlobalEventHandlers.onkeypress")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("keypress")}} event is raised.
- {{domxref("GlobalEventHandlers.onkeyup")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("keyup")}} event is raised.
- {{domxref("GlobalEventHandlers.onload")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("load")}} event is raised.
- {{domxref("GlobalEventHandlers.onloadeddata")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("loadeddata")}} event is raised.
- {{domxref("GlobalEventHandlers.onloadedmetadata")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("loadedmetadata")}} event is raised.
- {{domxref("GlobalEventHandlers.onloadstart")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("loadstart")}} event is raised.
- {{domxref("GlobalEventHandlers.onmousedown")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mousedown")}} event is raised.
- {{domxref("GlobalEventHandlers.onmouseenter")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mouseenter")}} event is raised.
- {{domxref("GlobalEventHandlers.onmouseleave")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mouseleave")}} event is raised.
- {{domxref("GlobalEventHandlers.onmousemove")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mousemove")}} event is raised.
- {{domxref("GlobalEventHandlers.onmouseout")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mouseout")}} event is raised.
- {{domxref("GlobalEventHandlers.onmouseover")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mouseover")}} event is raised.
- {{domxref("GlobalEventHandlers.onmouseup")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mouseup")}} event is raised.
- {{domxref("GlobalEventHandlers.onmousewheel")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("mousewheel")}} event is raised.
- {{domxref("GlobalEventHandlers.onpause")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pause")}} event is raised.
- {{domxref("Document.onpaste")}} {{non-standard_inline}}
- Represents the event handling code for the {{event("paste")}} event.
- {{domxref("GlobalEventHandlers.onplay")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("play")}} event is raised.
- {{domxref("GlobalEventHandlers.onplaying")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("playing")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerdown")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerdown")}} event is raised.
- {{domxref("Document.onpointerlockchange")}} {{experimental_inline}}
- Represents the event handling code for the {{event("pointerlockchange")}} event.
- {{domxref("Document.onpointerlockerror")}} {{experimental_inline}}
- Represetnts the event handling code for the {{event("pointerlockerror")}} event.
- {{domxref("GlobalEventHandlers.onpointermove")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointermove")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerup")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerup")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointercancel")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointercancel")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerover")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerover")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerout")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerout")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerenter")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerevent")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerleave")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerleave")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerlockchange")}} {{experimental_inline}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerlockchange")}} event is raised.
- {{domxref("GlobalEventHandlers.onpointerlockerror")}} {{experimental_inline}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pointerlockerror")}} event is raised.
- {{domxref("GlobalEventHandlers.onprogress")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("progress")}} event is raised.
- {{domxref("GlobalEventHandlers.onratechange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("ratechange")}} event is raised.
- {{domxref("Document.onreadystatechange")}} {{gecko_minversion_inline("1.9.2")}}
- Represents the event handling code for the {{event("readystatechange")}} event.
- {{domxref("GlobalEventHandlers.onreset")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("reset")}} event is raised.
- {{domxref("GlobalEventHandlers.onscroll")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("scroll")}} event is raised.
- {{domxref("GlobalEventHandlers.onseeked")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("seeked")}} event is raised.
- {{domxref("GlobalEventHandlers.onseeking")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("seeking")}} event is raised.
- {{domxref("GlobalEventHandlers.onselect")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("select")}} event is raised.
- {{domxref("GlobalEventHandlers.onselectstart")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("selectstart")}} event is raised.
- {{domxref("Document.onselectionchange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("selectionchange")}} event is raised.
- {{domxref("GlobalEventHandlers.onshow")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("show")}} event is raised.
- {{domxref("GlobalEventHandlers.onsort")}} {{experimental_inline}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("sort")}} event is raised.
- {{domxref("GlobalEventHandlers.onstalled")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("stalled")}} event is raised.
- {{domxref("GlobalEventHandlers.onsubmit")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("submit")}} event is raised.
- {{domxref("GlobalEventHandlers.onsuspend")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("suspend")}} event is raised.
- {{domxref("GlobalEventHandlers.ontimeupdate")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("timeupdate")}} event is raised.
- {{domxref("GlobalEventHandlers.onvolumechange")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("volumechange")}} event is raised.
- {{domxref("GlobalEventHandlers.onwaiting")}}
- Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("waiting")}} event is raised.
- {{domxref("Document.onwheel")}} {{non-standard_inline}}
- Represents the event handling code for the {{event("wheel")}} event.
Methods
This interface also inherits from the {{domxref("Node")}} and {{domxref("EventTarget")}} interfaces.
- {{domxref("Document.adoptNode()")}}
- Adopt node from an external document.
- {{domxref("Document.captureEvents()")}} {{Deprecated_inline}}
- See {{domxref("Window.captureEvents")}}.
- {{domxref("Document.caretPositionFromPoint()")}}{{experimental_inline}}
- Gets the {{domxref("CaretPosition")}} at or near the specified coordinates.
- {{domxref("Document.caretRangeFromPoint()")}}{{non-standard_inline}}
- Gets a {{Domxref("Range")}} object for the document fragment under the specified coordinates.
- {{domxref("Document.createAttribute()")}}
- Creates a new {{domxref("Attr")}} object 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}}
- Creates a new entity reference object and returns it.
- {{domxref("Document.createEvent()")}}
- Creates an event object.
- {{domxref("Document.createNodeIterator()")}}
- Creates a {{domxref("NodeIterator")}} object.
- {{domxref("Document.createProcessingInstruction()")}}
- Creates a new {{domxref("ProcessingInstruction")}} object.
- {{domxref("Document.createRange()")}}
- Creates a {{domxref("Range")}} object.
- {{domxref("Document.createTextNode()")}}
- Creates a text node.
- {{domxref("Document.createTouch()")}}
- Creates a {{domxref("Touch")}} object.
- {{domxref("Document.createTouchList()")}}
- Creates a {{domxref("TouchList")}} object.
- {{domxref("Document.createTreeWalker()")}}
- Creates a {{domxref("TreeWalker")}} object.
- {{domxref("Document.elementFromPoint()")}}{{experimental_inline}}
- Returns the topmost element at the specified coordinates.
- {{domxref("Document.elementsFromPoint()")}}{{experimental_inline}}
- Returns an array of all elements at the specified coordinates.
- {{domxref("Document.enableStyleSheetsForSet()")}}
- Enables the style sheets for the specified style sheet set.
- {{domxref("Document.exitPointerLock()")}} {{experimental_inline}}
- Release the pointer lock.
- {{domxref("Document.getAnimations()")}} {{experimental_inline}}
- Returns an array of all {{domxref("Animation")}} objects currently in effect whose target elements are descendants of the
document
.
- {{domxref("Document.getElementsByClassName()")}}
- Returns a list of elements with the given class 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("Document.importNode()")}}
- Returns a clone of a node from an external document.
- {{domxref("Document.normalizeDocument()")}} {{obsolete_inline}}
- Replaces entities, normalizes text nodes, etc.
- {{domxref("Document.registerElement()")}} {{experimental_inline}}
- Registers a web component.
- {{domxref("Document.releaseCapture()")}} {{non-standard_inline}} {{gecko_minversion_inline("2.0")}}
- Releases the current mouse capture if it's on an element in this document.
- {{domxref("Document.releaseEvents()")}} {{non-standard_inline}} {{Deprecated_inline}}
- See {{domxref("Window.releaseEvents()")}}.
- {{domxref("Document.routeEvent()")}} {{non-standard_inline}} {{obsolete_inline(24)}}
- See {{domxref("Window.routeEvent()")}}.
- {{domxref("Document.mozSetImageElement()")}} {{non-standard_inline}} {{gecko_minversion_inline("2.0")}}
- Allows you to change the element being used as the background image for a specified element ID.
The Document
interface is extended with the {{domxref("ParentNode")}} interface:
- {{domxref("document.getElementById","document.getElementById(String id)")}}
- Returns an object reference to the identified element.
- {{domxref("document.querySelector","document.querySelector(String selector)")}} {{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","document.querySelectorAll(String selector)")}} {{gecko_minversion_inline("1.9.1")}}
- Returns a list of all the Element nodes within the document that match the specified selectors.
The Document
interface is extended with the {{domxref("XPathEvaluator")}} interface:
- {{domxref("document.createExpression","document.createExpression(String expression, XPathNSResolver resolver)")}}
- Compiles an
XPathExpression
which can then be used for (repeated) evaluations.
- {{domxref("document.createNSResolver","document.createNSResolver(Node resolver)")}}
- Creates an {{domxref("XPathNSResolver")}} object.
- {{domxref("document.evaluate","document.evaluate(String expression, Node contextNode, XPathNSResolver resolver, Number type, Object result)")}}
- Evaluates an XPath expression.
Extension for HTML documents
The Document
interface for HTML documents inherit from the {{domxref("HTMLDocument")}} interface or, since HTML5, is extended for such documents:
- {{domxref("document.clear()")}} {{non-standard_inline}} {{Deprecated_inline}}
- In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.
- {{domxref("document.close()")}}
- Closes a document stream for writing.
- {{domxref("document.execCommand","document.execCommand(String command[, Boolean showUI[, String value]])")}}
- On an editable document, executes a formating command.
- {{domxref("document.getElementsByName","document.getElementsByName(String name)")}}
- Returns a list of elements with the given name.
- {{domxref("document.getSelection()")}}
- Returns a {{domxref("Selection")}} object related to text selected in the document.
- {{domxref("document.hasFocus()")}}
- Returns
true
if the focus is currently located anywhere inside the specified document.
- {{domxref("document.open()")}}
- Opens a document stream for writing.
- {{domxref("document.queryCommandEnabled","document.queryCommandEnabled(String command)")}}
- Returns true if the formating command can be executed on the current range.
- {{domxref("document.queryCommandIndeterm","document.queryCommandIndeterm(String command)")}}
- Returns true if the formating command is in an indeterminate state on the current range.
- {{domxref("document.queryCommandState","document.queryCommandState(String command)")}}
- Returns true if the formating command has been executed on the current range.
- {{domxref("document.queryCommandSupported","document.queryCommandSupported(String command)")}}
- Returns true if the formating command is supported on the current range.
- {{domxref("document.queryCommandValue","document.queryCommandValue(String command)")}}
- Returns the current value of the current range for a formating command.
- {{domxref("document.write","document.write(String text)")}}
- Writes text in a document.
- {{domxref("document.writeln","document.writeln(String text)")}}
- Writes a line of text in a document.
Specifications
Specification |
Status |
Comment |
{{SpecName('Selection API', '', 'Extend Document and GlobalEventHandlers')}} |
{{Spec2('Selection API')}} |
Adds onselectstart and onselectionchange . |
{{SpecName('DOM1','#i-Document','Document')}} |
{{Spec2('DOM1')}} |
Initial definition for the interface |
{{SpecName('DOM2 Core','#i-Document','Document')}} |
{{Spec2('DOM2 Core')}} |
Supersede DOM 1 |
{{SpecName('DOM3 Core','#i-Document','Document')}} |
{{Spec2('DOM3 Core')}} |
Supersede DOM 2 |
{{SpecName('DOM WHATWG','#interface-document','Document')}} |
{{Spec2('DOM WHATWG')}} |
Intend to supersede DOM 3 |
{{SpecName('HTML WHATWG','dom.html#the-document-object','Document')}} |
{{Spec2('HTML WHATWG')}} |
Turn the {{domxref("HTMLDocument")}} interface into a Document extension. |
{{SpecName('DOM3 XPath','xpath.html#XPathEvaluator','XPathEvaluator')}} |
{{Spec2('DOM3 XPath')}} |
Define the {{domxref("XPathEvaluator")}} interface which extend document. |
{{SpecName('HTML Editing','#dom-document-getselection','Document')}} |
{{Spec2('HTML Editing')}} |
Extend the Document interface |
{{SpecName('CSSOM View','#extensions-to-the-document-interface','Document')}} |
{{Spec2('CSSOM View')}} |
Extend the Document interface |
{{SpecName('CSSOM','#extensions-to-the-document-interface','Document')}} |
{{Spec2('CSSOM')}} |
Extend the Document interface |
{{SpecName('Pointer Lock','#extensions-to-the-document-interface','Document')}} |
{{Spec2('Pointer Lock')}} |
Extend the Document interface |
Browser compatibility notes
Firefox notes
Mozilla defines a set of non-standard properties made only for XUL content:
- {{domxref("document.currentScript")}} {{non-standard_inline}} {{gecko_minversion_inline("2.0")}}
- Returns the {{HTMLElement("script")}} element that is currently executing.
- {{domxref("document.documentURIObject")}} {{gecko_minversion_inline("1.9")}}
- (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).
- {{domxref("document.popupNode")}}
- Returns the node upon which a popup was invoked.
- {{domxref("document.tooltipNode")}}
- Returns the node which is the target of the current tooltip.
Mozilla also define some non-standard methods:
- {{domxref("document.execCommandShowHelp")}} {{obsolete_inline("14.0")}}
- This method never did anything and always threw an exception, so it was removed in Gecko 14.0 {{geckoRelease("14.0")}}.
- {{domxref("document.getBoxObjectFor")}} {{obsolete_inline}}
- Use the {{domxref("Element.getBoundingClientRect()")}} method instead.
- {{domxref("document.loadOverlay")}} {{Fx_minversion_inline("1.5")}}
- Loads a XUL overlay dynamically. This only works in XUL documents.
- {{domxref("document.queryCommandText")}} {{obsolete_inline("14.0")}}
- This method never did anything but throw an exception, and was removed in Gecko 14.0 {{geckoRelease("14.0")}}.
Internet Explorer notes
Microsoft defines some non-standard properties:
- {{domxref("document.fileSize")}}* {{non-standard_inline}} {{obsolete_inline}}
- Returns size in bytes of the document. Starting with Internet Explorer 11, that property is no longer supported. See MSDN.
- Internet Explorer does not support all methods from the
Node
interface in the Document
interface:
- {{domxref("document.contains")}}
- As a work-around,
document.body.contains()
can be used.