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 <body>
and <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:
document
in document's scripts. (The same document can also be referred to as window.document
.)contentDocument
property.responseXML
of an XMLHttpRequest
object.ownerDocument
property.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:
Document
and Node
interfaces, meaning that the "core" properties and methods are available for all kinds of documents.HTMLDocument
interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor).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:
Detailed browser compatibility tables are located at the pages describing each property or method.
readystatechange
event.
Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)
, 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.
<script>
elements on the document.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
. Setter throws DOMException."1.0"
if the declaration is absent. Setter throws DOMException.createElement("a")
.createElement("applet")
.createElement("area")
.createElement("audio")
.createElement("br")
.createElement("base")
.createElement("basefont")
.createElement("body")
.createElement("button")
.createElement("canvas")
.createElement("content")
.createElement("dl")
.createElement("datalist")
.createElement("details")
.createElement("dir")
.createElement("div")
.createElement("embed")
.createElement("fieldset")
.createElement("font")
.createElement("form")
.createElement("frame")
.createElement("frameset")
.createElement("hr")
.createElement("head")
.createElement("html")
.createElement("iframe")
.createElement("img")
.createElement("input")
.createElement("keygen")
.createElement("li")
.createElement("label")
.createElement("legend")
.createElement("link")
.createElement("map")
.createElement("marquee")
.createElement("media")
.createElement("menu")
.createElement("meta")
.createElement("meter")
.createElement("mod")
.createElement("ol")
.createElement("object")
.createElement("optgroup")
.createElement("option")
.createElement("output")
.createElement("p")
.createElement("param")
.createElement("pre")
.createElement("progress")
.createElement("quote")
.createElement("script")
.createElement("select")
.createElement("shadow")
.createElement("source")
.createElement("span")
.createElement("style")
.createElement("caption")
.createElement("td")
.createElement("col")
.createElement("table")
.createElement("tr")
.createElement("thead")
.createElement("textarea")
.createElement("title")
.createElement("track")
.createElement("ul")
.createElement("video")
.