Javascript Reference - HTML DOM Document Objects








The document object is the root node of the HTML document and the "owner" of all other nodes.

The document is a part of the window object and can be accessed as window.document.

Browser Support

Documents Yes Yes Yes Yes Yes

Document Object Properties and Methods

The following properties and methods can be used on HTML documents.

Property / Method Description
document.addEventListener() Add an event handler to the document
document.adoptNode(node) Get an adopted node from another document to this document
document.anchors Get a list of the anchors in the document
document.applets Get a list of the applets in the document
document.baseURI Get the absolute base URI of a document
document.body Get the body element of the document
document.close() Close the output stream opened with document.open()
document.cookie Get all cookies in the document
document.createAttribute() Create an attribute node
document.createComment() Create a Comment node with the specified text
document.createDocumentFragment() Create an empty DocumentFragment node
document.createElement() Create an Element node
document.createTextNode() Create a Text node
document.doctype Get the Document Type Declaration associated with the document
document.documentElement Get the Document Element of the document
document.documentMode Get the mode used by the browser to render the document
document.documentURI Set or get the location of the document
document.domain Get the domain name of the server where the document is from
document.domConfig Returns the configuration used when invoking normalizeDocument()
document.embeds Get a list of the embeds in the document
document.forms Get a list of the forms in the document
document.getElementById() Get the element by ID attribute with the specified value
document.getElementsByClassName() Get a NodeList containing all elements with the specified class name
document.getElementsByName() Get all elements by a specified name
document.getElementsByTagName() Get a NodeList containing all elements with the specified tagname
document.head Get the head element of the document
document.images get a list of all the images in the document
document.implementation Get the DOMImplementation object that handles this document
document.importNode() Imports a node from another document
document.inputEncoding Get the encoding, character set, used for the document
document.lastModified Get when the document was last modified
document.links Get a list of all links in the document
document.normalize() Remove empty Text nodes, and joins adjacent nodes
document.normalizeDocument() Removes empty Text nodes, and joins adjacent nodes
document.open() Open an HTML output stream to output from document.write()
document.querySelector() Get the first element that matches a specified CSS selector(s) in the document
document.querySelectorAll() Get a NodeList containing all elements that matches a specified CSS selector(s) in the document
document.readyState Get the loading status of the document
document.referrer Get the URL of the document that loaded the current document
document.removeEventListener() Remove an event handler from the document
document.renameNode() Renames the specified node
document.scripts Get a list of all the scripts in the document
document.strictErrorChecking Sets or gets whether error-checking is on
document.title Sets or gets the title of the document
document.URL Get the full URL of the document
document.write() Write String value to a document
document.writeln() Same as write(), but adds a newline character after