Definition
DOM Standard defines Document
Document includes NonElementParentNode;
Document includes DocumentOrShadowRoot;
Document includes ParentNode;
[Exposed=Window]
interface Document : Node {
constructor();
[SameObject] readonly attribute DOMImplementation implementation;
readonly attribute USVString URL;
readonly attribute USVString documentURI;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
readonly attribute DOMString charset; // legacy alias of .characterSet
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;
readonly attribute DocumentType? doctype;
readonly attribute Element? documentElement;
HTMLCollection getElementsByTagName(DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[CEReactions, NewObject] Element createElement(DOMString localName, optional (DOMString or ElementCreationOptions) options = {});
[CEReactions, NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options = {});
[NewObject] DocumentFragment createDocumentFragment();
[NewObject] Text createTextNode(DOMString data);
[NewObject] CDATASection createCDATASection(DOMString data);
[NewObject] Comment createComment(DOMString data);
[NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
[CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false);
[CEReactions] Node adoptNode(Node node);
[NewObject] Attr createAttribute(DOMString localName);
[NewObject] Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName);
[NewObject] Event createEvent(DOMString interface); // legacy
[NewObject] Range createRange();
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
[NewObject] NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
[NewObject] TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
};
Document includes XPathEvaluatorBase;
This interface is extended in the following specifications:
- Font Metrics API Level 1
partial interface Document { FontMetrics measureElement(Element element); FontMetrics measureText(DOMString text, StylePropertyMapReadOnly styleMap); };
- Fullscreen API Standard
partial interface Document { [LegacyLenientSetter] readonly attribute boolean fullscreenEnabled; [LegacyLenientSetter, Unscopable] readonly attribute boolean fullscreen; // historical Promise<undefined> exitFullscreen(); attribute EventHandler onfullscreenchange; attribute EventHandler onfullscreenerror; };
- HTML Standard
[LegacyOverrideBuiltIns] partial interface Document { static Document parseHTMLUnsafe((TrustedHTML or DOMString) html); // resource metadata management [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location; attribute USVString domain; readonly attribute USVString referrer; attribute USVString cookie; readonly attribute DOMString lastModified; readonly attribute DocumentReadyState readyState; // DOM tree accessors getter object (DOMString name); [CEReactions] attribute DOMString title; [CEReactions] attribute DOMString dir; [CEReactions] attribute HTMLElement? body; readonly attribute HTMLHeadElement? head; [SameObject] readonly attribute HTMLCollection images; [SameObject] readonly attribute HTMLCollection embeds; [SameObject] readonly attribute HTMLCollection plugins; [SameObject] readonly attribute HTMLCollection links; [SameObject] readonly attribute HTMLCollection forms; [SameObject] readonly attribute HTMLCollection scripts; NodeList getElementsByName(DOMString elementName); readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only // dynamic markup insertion [CEReactions] Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored WindowProxy? open(USVString url, DOMString name, DOMString features); [CEReactions] undefined close(); [CEReactions] undefined write((TrustedHTML or DOMString)... text); [CEReactions] undefined writeln((TrustedHTML or DOMString)... text); // user interaction readonly attribute WindowProxy? defaultView; boolean hasFocus(); [CEReactions] attribute DOMString designMode; [CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = ""); boolean queryCommandEnabled(DOMString commandId); boolean queryCommandIndeterm(DOMString commandId); boolean queryCommandState(DOMString commandId); boolean queryCommandSupported(DOMString commandId); DOMString queryCommandValue(DOMString commandId); readonly attribute DocumentVisibilityState visibilityState; // special event handler IDL attributes that only apply to Document objects [LegacyLenientThis] attribute EventHandler onreadystatechange; attribute EventHandler onvisibilitychange; // also has obsolete members }; Document includes GlobalEventHandlers; partial interface Document { [CEReactions] attribute [LegacyNullToEmptyString] DOMString fgColor; [CEReactions] attribute [LegacyNullToEmptyString] DOMString linkColor; [CEReactions] attribute [LegacyNullToEmptyString] DOMString vlinkColor; [CEReactions] attribute [LegacyNullToEmptyString] DOMString alinkColor; [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor; [SameObject] readonly attribute HTMLCollection anchors; [SameObject] readonly attribute HTMLCollection applets; undefined clear(); undefined captureEvents(); undefined releaseEvents(); [SameObject] readonly attribute HTMLAllCollection all; };
- requestStorageAccessFor API
partial interface Document { Promise<undefined> requestStorageAccessFor(USVString requestedOrigin); };
- Extending Storage Access API (SAA) to non-cookie storage
partial interface Document { Promise<boolean> hasUnpartitionedCookieAccess(); };
- The Storage Access API
partial interface Document { Promise<boolean> hasStorageAccess(); Promise<undefined> requestStorageAccess(); };
- Prerendering Revamped
partial interface Document { readonly attribute boolean prerendering; // Under "special event handler IDL attributes that only apply to Document objects" attribute EventHandler onprerenderingchange; };
- Page Lifecycle
partial interface Document { attribute EventHandler onfreeze; attribute EventHandler onresume; readonly attribute boolean wasDiscarded; };
- URL Fragment Text Directives
partial interface Document { [SameObject] readonly attribute FragmentDirective fragmentDirective; };
- Private State Token API
partial interface Document { Promise<boolean> hasPrivateToken(USVString issuer); Promise<boolean> hasRedemptionRecord(USVString issuer); };
- CSS Font Loading Module Level 3
Document includes FontFaceSource;
- CSS Regions Module Level 1
partial interface Document { readonly attribute NamedFlowMap namedFlows; };
- CSS View Transitions Module Level 2
partial interface Document { ViewTransition startViewTransition(optional (ViewTransitionUpdateCallback or StartViewTransitionOptions) callbackOptions = {}); };
- CSSOM View Module
partial interface Document { Element? elementFromPoint(double x, double y); sequence<Element> elementsFromPoint(double x, double y); CaretPosition? caretPositionFromPoint(double x, double y, optional CaretPositionFromPointOptions options = {}); readonly attribute Element? scrollingElement; }; Document includes GeometryUtils;
- Permissions Policy
partial interface Document { [SameObject] readonly attribute PermissionsPolicy permissionsPolicy; };
- Picture-in-Picture
partial interface Document { readonly attribute boolean pictureInPictureEnabled; [NewObject] Promise<undefined> exitPictureInPicture(); };
- Pointer Lock 2.0
partial interface Document { attribute EventHandler onpointerlockchange; attribute EventHandler onpointerlockerror; undefined exitPointerLock(); };
- Selection API
partial interface Document { Selection? getSelection(); };
- Scalable Vector Graphics (SVG) 2
partial interface Document { readonly attribute SVGSVGElement? rootElement; };
- Web Animations
partial interface Document { readonly attribute DocumentTimeline timeline; };
Consolidated IDL (across mixin and partials)
[Exposed=Window]
interface Document : Node {
constructor();
[SameObject] readonly attribute DOMImplementation implementation;
readonly attribute USVString URL;
readonly attribute USVString documentURI;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
readonly attribute DOMString charset; // legacy alias of .characterSet
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;
readonly attribute DocumentType? doctype;
readonly attribute Element? documentElement;
HTMLCollection getElementsByTagName(DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[CEReactions, NewObject] Element createElement(DOMString localName, optional (DOMString or ElementCreationOptions) options = {});
[CEReactions, NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options = {});
[NewObject] DocumentFragment createDocumentFragment();
[NewObject] Text createTextNode(DOMString data);
[NewObject] CDATASection createCDATASection(DOMString data);
[NewObject] Comment createComment(DOMString data);
[NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
[CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false);
[CEReactions] Node adoptNode(Node node);
[NewObject] Attr createAttribute(DOMString localName);
[NewObject] Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName);
[NewObject] Event createEvent(DOMString interface); // legacy
[NewObject] Range createRange();
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
[NewObject] NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
[NewObject] TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
Element? getElementById(DOMString elementId);
[SameObject] readonly attribute HTMLCollection children;
readonly attribute Element? firstElementChild;
readonly attribute Element? lastElementChild;
readonly attribute unsigned long childElementCount;
[CEReactions, Unscopable] undefined prepend((Node or DOMString)... nodes);
[CEReactions, Unscopable] undefined append((Node or DOMString)... nodes);
[CEReactions, Unscopable] undefined replaceChildren((Node or DOMString)... nodes);
Element? querySelector(DOMString selectors);
[NewObject] NodeList querySelectorAll(DOMString selectors);
[NewObject] XPathExpression createExpression(DOMString expression, optional XPathNSResolver? resolver = null);
Node createNSResolver(Node nodeResolver); // legacy
// XPathResult.ANY_TYPE = 0
XPathResult evaluate(DOMString expression, Node contextNode, optional XPathNSResolver? resolver = null, optional unsigned short type = 0, optional XPathResult? result = null);
FontMetrics measureElement(Element element);
FontMetrics measureText(DOMString text, StylePropertyMapReadOnly styleMap);
[LegacyLenientSetter] readonly attribute boolean fullscreenEnabled;
[LegacyLenientSetter, Unscopable] readonly attribute boolean fullscreen; // historical
Promise<undefined> exitFullscreen();
attribute EventHandler onfullscreenchange;
attribute EventHandler onfullscreenerror;
static Document parseHTMLUnsafe((TrustedHTML or DOMString) html);
// resource metadata management
[PutForwards=href, LegacyUnforgeable] readonly attribute Location? location;
attribute USVString domain;
readonly attribute USVString referrer;
attribute USVString cookie;
readonly attribute DOMString lastModified;
readonly attribute DocumentReadyState readyState;
// DOM tree accessors
getter object (DOMString name);
[CEReactions] attribute DOMString title;
[CEReactions] attribute DOMString dir;
[CEReactions] attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
[SameObject] readonly attribute HTMLCollection images;
[SameObject] readonly attribute HTMLCollection embeds;
[SameObject] readonly attribute HTMLCollection plugins;
[SameObject] readonly attribute HTMLCollection links;
[SameObject] readonly attribute HTMLCollection forms;
[SameObject] readonly attribute HTMLCollection scripts;
NodeList getElementsByName(DOMString elementName);
readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only
// dynamic markup insertion
[CEReactions] Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored
WindowProxy? open(USVString url, DOMString name, DOMString features);
[CEReactions] undefined close();
[CEReactions] undefined write((TrustedHTML or DOMString)... text);
[CEReactions] undefined writeln((TrustedHTML or DOMString)... text);
// user interaction
readonly attribute WindowProxy? defaultView;
boolean hasFocus();
[CEReactions] attribute DOMString designMode;
[CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
boolean queryCommandEnabled(DOMString commandId);
boolean queryCommandIndeterm(DOMString commandId);
boolean queryCommandState(DOMString commandId);
boolean queryCommandSupported(DOMString commandId);
DOMString queryCommandValue(DOMString commandId);
readonly attribute DocumentVisibilityState visibilityState;
// special event handler IDL attributes that only apply to Document objects
[LegacyLenientThis] attribute EventHandler onreadystatechange;
attribute EventHandler onvisibilitychange;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString fgColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString linkColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString vlinkColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString alinkColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor;
[SameObject] readonly attribute HTMLCollection anchors;
[SameObject] readonly attribute HTMLCollection applets;
undefined clear();
undefined captureEvents();
undefined releaseEvents();
[SameObject] readonly attribute HTMLAllCollection all;
attribute EventHandler onabort;
attribute EventHandler onauxclick;
attribute EventHandler onbeforeinput;
attribute EventHandler onbeforematch;
attribute EventHandler onbeforetoggle;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler onclose;
attribute EventHandler oncontextlost;
attribute EventHandler oncontextrestored;
attribute EventHandler oncopy;
attribute EventHandler oncuechange;
attribute EventHandler oncut;
attribute EventHandler ondblclick;
attribute EventHandler ondrag;
attribute EventHandler ondragend;
attribute EventHandler ondragenter;
attribute EventHandler ondragleave;
attribute EventHandler ondragover;
attribute EventHandler ondragstart;
attribute EventHandler ondrop;
attribute EventHandler ondurationchange;
attribute EventHandler onemptied;
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler onformdata;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
attribute EventHandler onkeypress;
attribute EventHandler onkeyup;
attribute EventHandler onload;
attribute EventHandler onloadeddata;
attribute EventHandler onloadedmetadata;
attribute EventHandler onloadstart;
attribute EventHandler onmousedown;
[LegacyLenientThis] attribute EventHandler onmouseenter;
[LegacyLenientThis] attribute EventHandler onmouseleave;
attribute EventHandler onmousemove;
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
attribute EventHandler onpaste;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
attribute EventHandler onprogress;
attribute EventHandler onratechange;
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
attribute EventHandler onscrollend;
attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onslotchange;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
attribute EventHandler ontimeupdate;
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
attribute EventHandler onwebkitanimationend;
attribute EventHandler onwebkitanimationiteration;
attribute EventHandler onwebkitanimationstart;
attribute EventHandler onwebkittransitionend;
attribute EventHandler onwheel;
Promise<undefined> requestStorageAccessFor(USVString requestedOrigin);
Promise<boolean> hasUnpartitionedCookieAccess();
Promise<boolean> hasStorageAccess();
Promise<undefined> requestStorageAccess();
readonly attribute boolean prerendering;
// Under "special event handler IDL attributes that only apply to Document objects"
attribute EventHandler onprerenderingchange;
attribute EventHandler onfreeze;
attribute EventHandler onresume;
readonly attribute boolean wasDiscarded;
[SameObject] readonly attribute FragmentDirective fragmentDirective;
Promise<boolean> hasPrivateToken(USVString issuer);
Promise<boolean> hasRedemptionRecord(USVString issuer);
readonly attribute FontFaceSet fonts;
readonly attribute NamedFlowMap namedFlows;
ViewTransition startViewTransition(optional (ViewTransitionUpdateCallback or StartViewTransitionOptions) callbackOptions = {});
Element? elementFromPoint(double x, double y);
sequence<Element> elementsFromPoint(double x, double y);
CaretPosition? caretPositionFromPoint(double x, double y, optional CaretPositionFromPointOptions options = {});
readonly attribute Element? scrollingElement;
sequence<DOMQuad> getBoxQuads(optional BoxQuadOptions options = {});
DOMQuad convertQuadFromNode(DOMQuadInit quad, GeometryNode from, optional ConvertCoordinateOptions options = {});
DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options = {});
DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options = {});
[SameObject] readonly attribute PermissionsPolicy permissionsPolicy;
readonly attribute boolean pictureInPictureEnabled;
[NewObject] Promise<undefined> exitPictureInPicture();
attribute EventHandler onpointerlockchange;
attribute EventHandler onpointerlockerror;
undefined exitPointerLock();
Selection? getSelection();
readonly attribute SVGSVGElement? rootElement;
readonly attribute DocumentTimeline timeline;
};
Methods and attributes that return objects implementing Document
Document()
Node.ownerDocument
DOMImplementation.createHTMLDocument()
XSLTProcessor.transformToDocument()
Document.parseHTMLUnsafe()
Document.open()
HTMLIFrameElement.contentDocument
HTMLIFrameElement.getSVGDocument()
HTMLEmbedElement.getSVGDocument()
HTMLObjectElement.contentDocument
HTMLObjectElement.getSVGDocument()
Window.document
DOMParser.parseFromString()
HTMLFrameElement.contentDocument
IntersectionObserver.root
GetSVGDocument.getSVGDocument()
XMLHttpRequest.responseXML
Referring IDL interfaces/dictionaries
Referring specifications
- Font Metrics API Level 1 refers to
Document
- Fullscreen API Standard refers to
Document
- HTML Standard refers to
Document
- requestStorageAccessFor API refers to
Document
- Extending Storage Access API (SAA) to non-cookie storage refers to
Document
- The Storage Access API refers to
Document
- Prerendering Revamped refers to
Document
- Page Lifecycle refers to
Document
- URL Fragment Text Directives refers to
Document
- Private State Token API refers to
Document
- CSS Regions Module Level 1 refers to
Document
- CSS View Transitions Module Level 2 refers to
Document
- CSSOM View Module refers to
Document
- Intersection Observer refers to
Document
- Permissions Policy refers to
Document
- Picture-in-Picture refers to
Document
- Pointer Lock 2.0 refers to
Document
- Selection API refers to
Document
- Scalable Vector Graphics (SVG) 2 refers to
Document
- Web Animations refers to
Document
- XMLHttpRequest Standard refers to
Document