diff options
Diffstat (limited to 'files/hu/web/api/document/index.html')
-rw-r--r-- | files/hu/web/api/document/index.html | 665 |
1 files changed, 665 insertions, 0 deletions
diff --git a/files/hu/web/api/document/index.html b/files/hu/web/api/document/index.html new file mode 100644 index 0000000000..a8181b06b7 --- /dev/null +++ b/files/hu/web/api/document/index.html @@ -0,0 +1,665 @@ +--- +title: Document +slug: Web/API/Document +tags: + - API + - DOM + - Document + - Interface + - NeedsTranslation + - Reference + - TopicStub +translation_of: Web/API/Document +--- +<div>{{APIRef("DOM")}}</div> + +<p><span class="seoSummary">The <strong><code>Document</code></strong> interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the <a href="/en-US/docs/Using_the_W3C_DOM_Level_1_Core">DOM tree</a>.</span> The DOM tree includes elements such as {{HTMLElement("body")}} and {{HTMLElement("table")}}, among <a href="/en-US/docs/Web/HTML/Element">many others</a>. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document.</p> + +<p>{{InheritanceDiagram}}</p> + +<p>The <code>Document</code> interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g. <a href="/en-US/docs/HTML">HTML</a>, <a href="/en-US/docs/XML">XML</a>, SVG, …), a larger API is available: HTML documents, served with the <code>"text/html"</code> content type, also implement the {{DOMxRef("HTMLDocument")}} interface, whereas XML and SVG documents implement the {{DOMxRef("XMLDocument")}} interface.</p> + +<h2 id="Constructor">Constructor</h2> + +<dl> + <dt>{{DOMxRef("Document.Document", "Document()")}}</dt> + <dd>Creates a new <code>Document</code> object.</dd> +</dl> + +<h2 id="Properties">Properties</h2> + +<p><em>This interface also inherits from the {{DOMxRef("Node")}} and {{DOMxRef("EventTarget")}} interfaces.</em></p> + +<dl> + <dt>{{DOMxRef("Document.anchors")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of all of the anchors in the document.</dd> + <dt>{{DOMxRef("Document.body")}}</dt> + <dd>Returns the {{HTMLElement("body")}} or {{htmlelement("frameset")}} node of the current document.</dd> + <dt>{{DOMxRef("Document.characterSet")}}{{ReadOnlyInline}}</dt> + <dd>Returns the character set being used by the document.</dd> + <dt>{{DOMxRef("Document.compatMode")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> + <dd>Indicates whether the document is rendered in <em>quirks</em> or <em>strict</em> mode.</dd> + <dt>{{DOMxRef("Document.contentType")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> + <dd>Returns the Content-Type from the MIME Header of the current document.</dd> + <dt>{{DOMxRef("Document.doctype")}}{{ReadOnlyInline}}</dt> + <dd>Returns the Document Type Definition (DTD) of the current document.</dd> + <dt>{{DOMxRef("Document.documentElement")}}{{ReadOnlyInline}}</dt> + <dd>Returns the {{DOMxRef("Element")}} that is a direct child of the document. For HTML documents, this is normally the {{DOMxRef("HTMLHtmlElement")}} object representing the document's {{HTMLElement("html")}} element.</dd> + <dt>{{DOMxRef("Document.documentURI")}}{{ReadOnlyInline}}</dt> + <dd>Returns the document location as a string.</dd> + <dt>{{DOMxRef("Document.embeds")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of the embedded {{HTMLElement('embed')}} elements within the current document.</dd> + <dt>{{DOMxRef("Document.fonts")}}</dt> + <dd>Returns the {{DOMxRef("FontFaceSet")}} interface of the current document.</dd> + <dt>{{DOMxRef("Document.forms")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of the {{HTMLElement("form")}} elements within the current document.</dd> + <dt>{{DOMxRef("Document.head")}}{{ReadOnlyInline}}</dt> + <dd>Returns the {{HTMLElement("head")}} element of the current document.</dd> + <dt>{{DOMxRef("Document.hidden")}}{{ReadOnlyInline}}</dt> + <dd>Returns a Boolean value indicating if the page is considered hidden or not.</dd> + <dt>{{DOMxRef("Document.images")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of the images in the current document.</dd> + <dt>{{DOMxRef("Document.implementation")}}{{ReadOnlyInline}}</dt> + <dd>Returns the DOM implementation associated with the current document.</dd> + <dt>{{DOMxRef("Document.lastStyleSheetSet")}}{{ReadOnlyInline}}</dt> + <dd>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 {{DOMxRef("Document.selectedStyleSheetSet","selectedStyleSheetSet")}}.</dd> + <dt>{{DOMxRef("Document.links")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of all the hyperlinks in the document.</dd> + <dt>{{DOMxRef("Document.mozSyntheticDocument")}} {{Non-standard_Inline}}</dt> + <dd>Returns a {{JSxRef("Boolean")}} that is <code>true</code> only if this document is synthetic, such as a standalone image, video, audio file, or the like.</dd> + <dt>{{DOMxRef("Document.plugins")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of the available plugins.</dd> + <dt>{{DOMxRef("Document.featurePolicy")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> + <dd>Returns the {{DOMxRef("FeaturePolicy")}} interface which provides a simple API for introspecting the feature policies applied to a specific document.</dd> + <dt>{{DOMxRef("Document.preferredStyleSheetSet")}}{{ReadOnlyInline}}</dt> + <dd>Returns the preferred style sheet set as specified by the page author.</dd> + <dt>{{DOMxRef("Document.scripts")}}{{ReadOnlyInline}}</dt> + <dd>Returns all the {{HTMLElement("script")}} elements on the document.</dd> + <dt>{{DOMxRef("Document.scrollingElement")}}{{ReadOnlyInline}}</dt> + <dd>Returns a reference to the {{DOMxRef("Element")}} that scrolls the document.</dd> + <dt>{{DOMxRef("Document.selectedStyleSheetSet")}}</dt> + <dd>Returns which style sheet set is currently in use.</dd> + <dt>{{DOMxRef("Document.styleSheetSets")}}{{ReadOnlyInline}}</dt> + <dd>Returns a list of the style sheet sets available on the document.</dd> + <dt>{{DOMxRef("Document.timeline")}}{{ReadOnlyInline}}</dt> + <dd>Returns timeline as a special instance of {{domxref("DocumentTimeline")}} that is automatically created on page load.</dd> + <dt>{{DOMxRef("Document.undoManager")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> + <dd>…</dd> + <dt>{{DOMxRef("Document.visibilityState")}}{{ReadOnlyInline}}</dt> + <dd>Returns a <code>string</code> denoting the visibility state of the document. Possible values are <code>visible</code>, <code>hidden</code>, <code>prerender</code>, and <code>unloaded</code>.</dd> +</dl> + +<p>The <code>Document</code> interface is extended with the {{DOMxRef("ParentNode")}} interface:</p> + +<p>{{page("/en-US/docs/Web/API/ParentNode","Properties")}}</p> + +<h3 id="Extensions_for_HTMLDocument">Extensions for HTMLDocument</h3> + +<p><em>The <code>Document</code> interface for HTML documents inherits from the {{DOMxRef("HTMLDocument")}} interface or, since HTML5, is extended for such documents.</em></p> + +<dl> + <dt>{{DOMxRef("Document.cookie")}}</dt> + <dd>Returns a semicolon-separated list of the cookies for that document or sets a single cookie.</dd> + <dt>{{DOMxRef("Document.defaultView")}}{{ReadOnlyInline}}</dt> + <dd>Returns a reference to the window object.</dd> + <dt>{{DOMxRef("Document.designMode")}}</dt> + <dd>Gets/sets the ability to edit the whole document.</dd> + <dt>{{DOMxRef("Document.dir")}}{{ReadOnlyInline}}</dt> + <dd>Gets/sets directionality (rtl/ltr) of the document.</dd> + <dt>{{DOMxRef("Document.domain")}}</dt> + <dd>Gets/sets the domain of the current document.</dd> + <dt>{{DOMxRef("Document.lastModified")}}{{ReadOnlyInline}}</dt> + <dd>Returns the date on which the document was last modified.</dd> + <dt>{{DOMxRef("Document.location")}}{{ReadOnlyInline}}</dt> + <dd>Returns the URI of the current document.</dd> + <dt>{{DOMxRef("Document.readyState")}}{{ReadOnlyInline}}</dt> + <dd>Returns loading status of the document.</dd> + <dt>{{DOMxRef("Document.referrer")}}{{ReadOnlyInline}}</dt> + <dd>Returns the URI of the page that linked to this page.</dd> + <dt>{{DOMxRef("Document.title")}}</dt> + <dd>Sets or gets the title of the current document.</dd> + <dt>{{DOMxRef("Document.URL")}}{{ReadOnlyInline}}</dt> + <dd>Returns the document location as a string.</dd> +</dl> + +<h3 id="Properties_included_from_DocumentOrShadowRoot">Properties included from DocumentOrShadowRoot</h3> + +<p><em>The <code>Document</code> interface includes the following properties defined on the {{DOMxRef("DocumentOrShadowRoot")}} mixin. Note that this is currently only implemented by Chrome; other browsers still implement them directly on the {{DOMxRef("Document")}} interface.</em></p> + +<dl> + <dt>{{DOMxRef("DocumentOrShadowRoot.activeElement")}}{{ReadOnlyInline}}</dt> + <dd>Returns the {{DOMxRef('Element')}} within the shadow tree that has focus.</dd> + <dt>{{DOMxRef("Document.fullscreenElement")}}{{ReadOnlyInline}}</dt> + <dd>The element that's currently in full screen mode for this document.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.pointerLockElement")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> + <dd>Returns the element set as the target for mouse events while the pointer is locked. <code>null</code> if lock is pending, pointer is unlocked, or if the target is in another document.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.styleSheets")}}{{ReadOnlyInline}}</dt> + <dd>Returns a {{DOMxRef('StyleSheetList')}} of {{DOMxRef('CSSStyleSheet')}} objects for stylesheets explicitly linked into, or embedded in a document.</dd> +</dl> + +<h3 id="Event_handlers">Event handlers</h3> + +<dl> + <dt>{{DOMxRef("Document.onafterscriptexecute")}} {{Non-standard_Inline}}</dt> + <dd>Represents the event handling code for the {{event("afterscriptexecute")}} event.</dd> + <dt>{{DOMxRef("Document.onbeforescriptexecute")}} {{Non-standard_Inline}}</dt> + <dd>Represents the event handling code for the {{event("beforescriptexecute")}} event.</dd> + <dt>{{DOMxRef("Document.oncopy")}} {{Non-standard_Inline}}</dt> + <dd>Represents the event handling code for the {{event("copy")}} event.</dd> + <dt>{{DOMxRef("Document.oncut")}} {{Non-standard_Inline}}</dt> + <dd>Represents the event handling code for the {{event("cut")}} event.</dd> + <dt>{{DOMxRef("Document.onfullscreenchange")}}</dt> + <dd>Is an {{DOMxRef("EventHandler")}} representing the code to be called when the {{event("fullscreenchange")}} event is raised.</dd> + <dt>{{DOMxRef("Document.onfullscreenerror")}}</dt> + <dd>Is an {{DOMxRef("EventHandler")}} representing the code to be called when the {{event("fullscreenerror")}} event is raised.</dd> + <dt>{{DOMxRef("Document.onpaste")}} {{Non-standard_Inline}}</dt> + <dd>Represents the event handling code for the {{event("paste")}} event.</dd> + <dt>{{DOMxRef("Document.onreadystatechange")}}</dt> + <dd>Represents the event handling code for the {{event("readystatechange")}} event.</dd> + <dt>{{DOMxRef("Document.onselectionchange")}} {{Experimental_Inline}}</dt> + <dd>Is an {{DOMxRef("EventHandler")}} representing the code to be called when the {{event("selectionchange")}} event is raised.</dd> + <dt>{{DOMxRef("Document.onvisibilitychange")}}</dt> + <dd>Is an {{DOMxRef("EventHandler")}} representing the code to be called when the {{event("visibilitychange")}} event is raised.</dd> +</dl> + +<p>The <code>Document</code> interface is extended with the {{DOMxRef("GlobalEventHandlers")}} interface:</p> + +<p>{{Page("/en-US/docs/Web/API/GlobalEventHandlers", "Properties")}}</p> + +<h3 id="Deprecated_properties">Deprecated properties</h3> + +<dl> + <dt>{{DOMxRef("Document.alinkColor")}} {{Deprecated_Inline}}</dt> + <dd>Returns or sets the color of active links in the document body.</dd> + <dt>{{DOMxRef("Document.all")}} {{Deprecated_Inline}} {{Non-standard_Inline}}</dt> + <dd>Provides access to all elements in the document — it returns an {{DOMxRef('HTMLAllCollection')}} rooted at the document node. This is a legacy, non-standard property and should not be used.</dd> + <dt>{{DOMxRef("Document.applets")}} {{Deprecated_Inline}}{{ReadOnlyInline}}</dt> + <dd>Returns an ordered list of the applets within a document.</dd> + <dt>{{DOMxRef("Document.bgColor")}} {{Deprecated_Inline}}</dt> + <dd>Gets/sets the background color of the current document.</dd> + <dt>{{DOMxRef("Document.charset")}} {{Deprecated_Inline}}{{ReadOnlyInline}}</dt> + <dd>Alias of {{DOMxRef("Document.characterSet")}}. Use this property instead.</dd> + <dt>{{DOMxRef("Document.domConfig")}} {{Deprecated_Inline}}</dt> + <dd>Should return a {{DOMxRef("DOMConfiguration")}} object.</dd> + <dt>{{DOMxRef("Document.fgColor")}} {{Deprecated_Inline}}</dt> + <dd>Gets/sets the foreground color, or text color, of the current document.</dd> + <dt>{{DOMxRef("Document.fullscreen")}} {{Obsolete_Inline}}</dt> + <dd><code>true</code> when the document is in {{DOMxRef("Using_full-screen_mode","full-screen mode")}}.</dd> + <dt>{{DOMxRef("Document.height")}} {{Non-standard_Inline}} {{Obsolete_Inline}}</dt> + <dd>Gets/sets the height of the current document.</dd> + <dt>{{DOMxRef("Document.inputEncoding")}} {{Deprecated_Inline}}{{ReadOnlyInline}}</dt> + <dd>Alias of {{DOMxRef("Document.characterSet")}}. Use this property instead.</dd> + <dt>{{DOMxRef("Document.linkColor")}} {{Deprecated_Inline}}</dt> + <dd>Gets/sets the color of hyperlinks in the document.</dd> + <dt>{{DOMxRef("Document.vlinkColor")}} {{Deprecated_Inline}}</dt> + <dd>Gets/sets the color of visited hyperlinks.</dd> + <dt>{{DOMxRef("Document.width")}} {{Non-standard_Inline}} {{Obsolete_Inline}}</dt> + <dd>Returns the width of the current document.</dd> + <dt>{{DOMxRef("Document.xmlEncoding")}} {{Deprecated_Inline}}</dt> + <dd>Returns the encoding as determined by the XML declaration.</dd> + <dt>{{DOMxRef("Document.xmlStandalone")}} {{Obsolete_Inline("Gecko10")}}</dt> + <dd>Returns <code>true</code> if the XML declaration specifies the document to be standalone (<em>e.g.,</em> An external part of the DTD affects the document's content), else <code>false</code>.</dd> + <dt>{{DOMxRef("Document.xmlVersion")}} {{Obsolete_Inline("Gecko10")}}</dt> + <dd>Returns the version number as specified in the XML declaration or <code>"1.0"</code> if the declaration is absent.</dd> +</dl> + +<h2 id="Methods">Methods</h2> + +<p><em>This interface also inherits from the {{DOMxRef("Node")}} and {{DOMxRef("EventTarget")}} interfaces.</em></p> + +<dl> + <dt>{{DOMxRef("Document.adoptNode()")}}</dt> + <dd>Adopt node from an external document.</dd> + <dt>{{DOMxRef("Document.captureEvents()")}} {{Deprecated_Inline}}</dt> + <dd>See {{DOMxRef("Window.captureEvents")}}.</dd> + <dt>{{DOMxRef("Document.caretRangeFromPoint()")}} {{Non-standard_Inline}}</dt> + <dd>Gets a {{DOMxRef("Range")}} object for the document fragment under the specified coordinates.</dd> + <dt>{{DOMxRef("Document.createAttribute()")}}</dt> + <dd>Creates a new {{DOMxRef("Attr")}} object 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}}</dt> + <dd>Creates a new entity reference object and returns it.</dd> + <dt>{{DOMxRef("Document.createEvent()")}}</dt> + <dd>Creates an event object.</dd> + <dt>{{DOMxRef("Document.createNodeIterator()")}}</dt> + <dd>Creates a {{DOMxRef("NodeIterator")}} object.</dd> + <dt>{{DOMxRef("Document.createProcessingInstruction()")}}</dt> + <dd>Creates a new {{DOMxRef("ProcessingInstruction")}} object.</dd> + <dt>{{DOMxRef("Document.createRange()")}}</dt> + <dd>Creates a {{DOMxRef("Range")}} object.</dd> + <dt>{{DOMxRef("Document.createTextNode()")}}</dt> + <dd>Creates a text node.</dd> + <dt>{{DOMxRef("Document.createTouch()")}} {{Deprecated_Inline}}</dt> + <dd>Creates a {{DOMxRef("Touch")}} object.</dd> + <dt>{{DOMxRef("Document.createTouchList()")}}</dt> + <dd>Creates a {{DOMxRef("TouchList")}} object.</dd> + <dt>{{DOMxRef("Document.createTreeWalker()")}}</dt> + <dd>Creates a {{DOMxRef("TreeWalker")}} object.</dd> + <dt>{{DOMxRef("Document.enableStyleSheetsForSet()")}}</dt> + <dd>Enables the style sheets for the specified style sheet set.</dd> + <dt>{{DOMxRef("Document.exitPointerLock()")}} {{Experimental_Inline}}</dt> + <dd>Release the pointer lock.</dd> + <dt>{{DOMxRef("Document.getAnimations()")}} {{Experimental_Inline}}</dt> + <dd>Returns an array of all {{DOMxRef("Animation")}} objects currently in effect, whose target elements are descendants of the <code>document</code>.</dd> + <dt>{{DOMxRef("Document.getElementsByClassName()")}}</dt> + <dd>Returns a list of elements with the given class 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("Document.hasStorageAccess()")}}</dt> + <dd>Returns a {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to its first-party storage.</dd> + <dt>{{DOMxRef("Document.importNode()")}}</dt> + <dd>Returns a clone of a node from an external document.</dd> + <dt>{{DOMxRef("Document.normalizeDocument()")}} {{Obsolete_Inline}}</dt> + <dd>Replaces entities, normalizes text nodes, etc.</dd> + <dt>{{DOMxRef("Document.releaseCapture()")}} {{Non-standard_Inline}} {{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()")}} {{Non-standard_Inline}} {{Deprecated_Inline}}</dt> + <dd>See {{DOMxRef("Window.releaseEvents()")}}.</dd> + <dt>{{DOMxRef("Document.requestStorageAccess()")}}</dt> + <dd>Returns a {{jsxref("Promise")}} that resolves if the access to first-party storage was granted, and rejects if access was denied.</dd> + <dt>{{DOMxRef("Document.routeEvent()")}} {{Non-standard_Inline}} {{Obsolete_Inline("Gecko24")}}</dt> + <dd>See {{DOMxRef("Window.routeEvent()")}}.</dd> + <dt>{{DOMxRef("Document.mozSetImageElement()")}} {{Non-standard_Inline}}</dt> + <dd>Allows you to change the element being used as the background image for a specified element ID.</dd> +</dl> + +<p>The <code>Document</code> interface is extended with the {{DOMxRef("ParentNode")}} interface:</p> + +<dl> + <dt>{{DOMxRef("Document.getElementById","document.getElementById(String id)")}}</dt> + <dd>Returns an object reference to the identified element.</dd> + <dt>{{DOMxRef("Document.querySelector()")}}</dt> + <dd>Returns the first Element node within the document, in document order, that matches the specified selectors.</dd> + <dt>{{DOMxRef("Document.querySelectorAll()")}}</dt> + <dd>Returns a list of all the Element nodes within the document that match the specified selectors.</dd> +</dl> + +<p>The <code>Document</code> interface is extended with the {{DOMxRef("XPathEvaluator")}} interface:</p> + +<dl> + <dt>{{DOMxRef("Document.createExpression()")}}</dt> + <dd>Compiles an <code><a href="/en-US/docs/XPathExpression" title="XPathExpression">XPathExpression</a></code> which can then be used for (repeated) evaluations.</dd> + <dt>{{DOMxRef("Document.createNSResolver()")}}</dt> + <dd>Creates an {{DOMxRef("XPathNSResolver")}} object.</dd> + <dt>{{DOMxRef("Document.evaluate()")}}</dt> + <dd>Evaluates an XPath expression.</dd> +</dl> + +<h3 id="Extension_for_HTML_documents">Extension for HTML documents</h3> + +<p>The <code>Document</code> interface for HTML documents inherit from the {{DOMxRef("HTMLDocument")}} interface or, since HTML5, is extended for such documents:</p> + +<dl> + <dt>{{DOMxRef("Document.clear()")}} {{Non-standard_Inline}} {{Deprecated_Inline}}</dt> + <dd>In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.</dd> + <dt>{{DOMxRef("Document.close()")}}</dt> + <dd>Closes a document stream for writing.</dd> + <dt>{{DOMxRef("Document.execCommand()")}}</dt> + <dd>On an editable document, executes a formating command.</dd> + <dt>{{DOMxRef("Document.getElementsByName()")}}</dt> + <dd>Returns a list of elements with the given name.</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.open()")}}</dt> + <dd>Opens a document stream for writing.</dd> + <dt>{{DOMxRef("Document.queryCommandEnabled()")}}</dt> + <dd>Returns true if the formating command can be executed on the current range.</dd> + <dt>{{DOMxRef("Document.queryCommandIndeterm()")}}</dt> + <dd>Returns true if the formating command is in an indeterminate state on the current range.</dd> + <dt>{{DOMxRef("Document.queryCommandState()")}}</dt> + <dd>Returns true if the formating command has been executed on the current range.</dd> + <dt>{{DOMxRef("Document.queryCommandSupported()")}}</dt> + <dd>Returns true if the formating command is supported on the current range.</dd> + <dt>{{DOMxRef("Document.queryCommandValue()")}}</dt> + <dd>Returns the current value of the current range for a formating command.</dd> + <dt>{{DOMxRef("Document.write()")}}</dt> + <dd>Writes text in a document.</dd> + <dt>{{DOMxRef("Document.writeln()")}}</dt> + <dd>Writes a line of text in a document.</dd> +</dl> + +<h3 id="Methods_included_from_DocumentOrShadowRoot">Methods included from DocumentOrShadowRoot</h3> + +<p><em>The <code>Document</code> interface includes the following methods defined on the {{DOMxRef("DocumentOrShadowRoot")}} mixin. Note that this is currently only implemented by Chrome; other browsers still implement them on the {{DOMxRef("Document")}} interface.</em></p> + +<dl> + <dt>{{DOMxRef("DocumentOrShadowRoot.getSelection()")}}</dt> + <dd>Returns a {{DOMxRef('Selection')}} object representing the range of text selected by the user, or the current position of the caret.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}}</dt> + <dd>Returns the topmost element at the specified coordinates.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.elementsFromPoint()")}}</dt> + <dd>Returns an array of all elements at the specified coordinates.</dd> + <dt>{{DOMxRef("DocumentOrShadowRoot.caretPositionFromPoint()")}}</dt> + <dd>Returns a {{DOMxRef('CaretPosition')}} object containing the DOM node containing the caret, and caret's character offset within that node.</dd> +</dl> + +<h2 id="Events">Events</h2> + +<p>Listen to these events using <code>addEventListener()</code> or by assigning an event listener to the <code>on<em>eventname</em></code> property of this interface.</p> + +<dl> + <dt>{{DOMxRef("Document/scroll_event", "scroll")}}</dt> + <dd>Fired when the document view or an element has been scrolled.<br> + Also available via the {{DOMxRef("GlobalEventHandlers.onscroll", "onscroll")}} property.</dd> + <dt>{{DOMxRef("Document/visibilitychange_event", "visibilitychange")}}</dt> + <dd>Fired when the content of a tab has become visible or has been hidden.<br> + Also available via the {{DOMxRef("Document.onvisibilitychange", "onvisibilitychange")}} property.</dd> + <dt>{{DOMxRef("Document/wheel_event","wheel")}}</dt> + <dd>Fired when the user rotates a wheel button on a pointing device (typically a mouse).<br> + Also available via the {{DOMxRef("GlobalEventHandlers.onwheel", "onwheel")}} property.</dd> +</dl> + +<h3 id="Animation_events">Animation events</h3> + +<dl> + <dt>{{DOMxRef("Document/animationcancel_event", "animationcancel")}}</dt> + <dd>Fired when an animation unexpectedly aborts.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onanimationcancel", "onanimationcancel")}} property.</dd> + <dt>{{DOMxRef("Document/animationend_event", "animationend")}}</dt> + <dd>Fired when an animation has completed normally.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onanimationend", "onanimationend")}} property.</dd> + <dt>{{DOMxRef("Document/animationiteration_event", "animationiteration")}}</dt> + <dd>Fired when an animation iteration has completed.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onanimationiteration", "onanimationiteration")}} property.</dd> + <dt>{{DOMxRef("Document/animationstart_event", "animationstart")}}</dt> + <dd>Fired when an animation starts.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onanimationstart", "onanimationstart")}} property.</dd> +</dl> + +<h3 id="Clipboard_events">Clipboard events</h3> + +<dl> + <dt>{{DOMxRef("Document/copy_event", "copy")}}</dt> + <dd>Fired when the user initiates a copy action through the browser's user interface.<br> + Also available via the {{DOMxRef("HTMLElement/oncopy", "oncopy")}} property.</dd> + <dt>{{DOMxRef("Document/cut_event", "cut")}}</dt> + <dd>Fired when the user initiates a cut action through the browser's user interface.<br> + Also available via the {{DOMxRef("HTMLElement/oncut", "oncut")}} property.</dd> + <dt>{{DOMxRef("Document/paste_event", "paste")}}</dt> + <dd>Fired when the user initiates a paste action through the browser's user interface.<br> + Also available via the {{DOMxRef("HTMLElement/onpaste", "onpaste")}} property.</dd> +</dl> + +<h3 id="Drag_drop_events">Drag & drop events</h3> + +<dl> + <dt>{{DOMxRef("Document/drag_event", "drag")}}</dt> + <dd>Fired every few hundred milliseconds as an element or text selection is being dragged by the user.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondrag", "ondrag")}} property.</dd> + <dt>{{DOMxRef("Document/dragend_event", "dragend")}}</dt> + <dd>Fired when a drag operation is being ended (by releasing a mouse button or hitting the escape key).<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondragend", "ondragend")}} property.</dd> + <dt>{{DOMxRef("Document/dragenter_event", "dragenter")}}</dt> + <dd>Fired when a dragged element or text selection enters a valid drop target.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondragenter", "ondragenter")}} property.</dd> + <dt>{{DOMxRef("Document/dragexit_event", "dragexit")}}</dt> + <dd>Fired when an element is no longer the drag operation's immediate selection target.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondragexit", "ondragexit")}} property.</dd> + <dt>{{DOMxRef("Document/dragleave_event", "dragleave")}}</dt> + <dd>Fired when a dragged element or text selection leaves a valid drop target.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondragleave", "ondragleave")}} property.</dd> + <dt>{{DOMxRef("Document/dragover_event", "dragover")}}</dt> + <dd>Fired when an element or text selection is being dragged over a valid drop target (every few hundred milliseconds).<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondragover", "ondragover")}} property.</dd> + <dt>{{DOMxRef("Document/dragstart_event", "dragstart")}}</dt> + <dd>Fired when the user starts dragging an element or text selection.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondragstart", "ondragstart")}} property.</dd> + <dt>{{DOMxRef("Document/drop_event", "drop")}}</dt> + <dd>Fired when an element or text selection is dropped on a valid drop target.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ondrop", "ondrop")}} property.</dd> +</dl> + +<h3 id="Fullscreen_events">Fullscreen events</h3> + +<dl> + <dt>{{DOMxRef("Document/fullscreenchange_event", "fullscreenchange")}}</dt> + <dd>Fired when the <code>Document</code> transitions into or out of <a href="/en-US/docs/Web/API/Fullscreen_API/Guide">full-screen</a> mode.<br> + Also available via the {{DOMxRef("Document.onfullscreenchange", "onfullscreenchange")}} property.</dd> + <dt><code><a href="/en-US/docs/Web/Events/fullscreenerror">fullscreenerror</a></code></dt> + <dd>Fired if an error occurs while attempting to switch into or out of <a href="/en-US/docs/Web/API/Fullscreen_API/Guide">full-screen</a> mode.<br> + Also available via the {{DOMxRef("Document.onfullscreenerror", "onfullscreenerror")}} property.</dd> + <dt> + <h3 id="Keyboard_events">Keyboard events</h3> + </dt> + <dt>{{DOMxRef("Document/keydown_event", "keydown")}}</dt> + <dd>Fired when a key is pressed.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onkeydown", "onkeydown")}} property.</dd> + <dt>{{DOMxRef("Document/keypress_event", "keypress")}}</dt> + <dd>Fired when a key that produces a character value is pressed down. {{Deprecated_Inline}}<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onkeypress", "onkeypress")}} property.</dd> + <dt>{{DOMxRef("Document/keyup_event", "keyup")}}</dt> + <dd>Fired when a key is released.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onkeyup", "onkeyup")}} property.</dd> +</dl> + +<h3 id="Load_unload_events">Load & unload events</h3> + +<dl> + <dt>{{DOMxRef("Document/DOMContentLoaded_event", "DOMContentLoaded")}}</dt> + <dd>Fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.</dd> + <dt>{{DOMxRef("Document/readystatechange_event", "readystatechange")}}</dt> + <dd>Fired when the {{DOMxRef("Document/readyState", "readyState")}} attribute of a document has changed.<br> + Also available via the <code>onreadystatechange</code> property.</dd> +</dl> + +<h3 id="Pointer_events">Pointer events</h3> + +<dl> + <dt>{{DOMxRef("Document/gotpointercapture_event", "gotpointercapture")}}</dt> + <dd>Fired when when an element captures a pointer using <code><a href="/en-US/docs/Web/API/Element/setPointerCapture">setPointerCapture()</a></code>.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ongotpointercapture", "ongotpointercapture")}} property.</dd> + <dt>{{DOMxRef("Document/lostpointercapture_event", "lostpointercapture")}}</dt> + <dd>Fired when a <a href="/en-US/docs/Web/API/Pointer_events#Pointer_capture">captured pointer</a> is released.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onlostpointercapture", "onlostpointercapture")}} property.</dd> + <dt>{{DOMxRef("Document/pointercancel_event", "pointercancel")}}</dt> + <dd>Fired when a pointer event is canceled.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointercancel", "onpointercancel")}} property.</dd> + <dt>{{DOMxRef("Document/pointerdown_event", "pointerdown")}}</dt> + <dd>Fired when a pointer becomes active.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerdown", "onpointerdown")}} property.</dd> + <dt>{{DOMxRef("Document/pointerenter_event", "pointerenter")}}</dt> + <dd>Fired when a pointer is moved into the hit test boundaries of an element or one of its descendants.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerenter", "onpointerenter")}} property.</dd> + <dt>{{DOMxRef("Document/pointerleave_event", "pointerleave")}}</dt> + <dd>Fired when a pointer is moved out of the hit test boundaries of an element.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerleave", "onpointerleave")}} property.</dd> + <dt>{{DOMxRef("Document/pointerlockchange_event", "pointerlockchange")}}</dt> + <dd>Fired when the pointer is locked/unlocked.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerlockchange", "onpointerlockchange")}} property.</dd> + <dt>{{DOMxRef("Document/pointerlockerror_event", "pointerlockerror")}}</dt> + <dd>Fired when locking the pointer failed.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerlockerror", "onpointerlockerror")}} property.</dd> + <dt>{{DOMxRef("Document/pointermove_event", "pointermove")}}</dt> + <dd>Fired when a pointer changes coordinates.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointermove", "onpointermove")}} property.</dd> + <dt>{{DOMxRef("Document/pointerout_event", "pointerout")}}</dt> + <dd>Fired when a pointer is moved out of the <em>hit test</em> boundaries of an element (among other reasons).<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerout", "onpointerout")}} property.</dd> + <dt>{{DOMxRef("Document/pointerover_event", "pointerover")}}</dt> + <dd>Fired when a pointer is moved into an element's hit test boundaries.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerover", "onpointerover")}} property.</dd> + <dt>{{DOMxRef("Document/pointerup_event", "pointerup")}}</dt> + <dd>Fired when a pointer is no longer active.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onpointerup", "onpointerup")}} property.</dd> +</dl> + +<h3 id="Selection_events">Selection events</h3> + +<dl> + <dt>{{DOMxRef("Document/selectionchange_event", "selectionchange")}}</dt> + <dd>Fired when the current text selection on a document is changed.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onselectionchange", "onselectionchange")}} property.</dd> + <dt>{{DOMxRef("Document/selectstart_event", "selectstart")}}</dt> + <dd>Fired when the user begins a new selection.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/onselectstart", "onselectstart")}} property.</dd> +</dl> + +<h3 id="Touch_events">Touch events</h3> + +<dl> + <dt>{{DOMxRef("Document/touchcancel_event", "touchcancel")}}</dt> + <dd>Fired when one or more touch points have been disrupted in an implementation-specific manner (for example, too many touch points are created).<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontouchcancel", "ontouchcancel")}} property.</dd> + <dt>{{DOMxRef("Document/touchend_event", "touchend")}}</dt> + <dd>Fired when one or more touch points are removed from the touch surface.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontouchend", "ontouchend")}} property</dd> + <dt>{{DOMxRef("Document/touchmove_event", "touchmove")}}</dt> + <dd>Fired when one or more touch points are moved along the touch surface.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontouchmove", "ontouchmove")}} property</dd> + <dt>{{DOMxRef("Document/touchstart_event", "touchstart")}}</dt> + <dd>Fired when one or more touch points are placed on the touch surface.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontouchstart", "ontouchstart")}} property</dd> +</dl> + +<h3 id="Transition_events">Transition events</h3> + +<dl> + <dt>{{DOMxRef("Document/transitioncancel_event", "transitioncancel")}}</dt> + <dd>Fired when a <a href="/en-US/docs/CSS/Using_CSS_transitions">CSS transition</a> is canceled.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontransitioncancel", "ontransitioncancel")}} property.</dd> + <dt>{{DOMxRef("Document/transitionend_event", "transitionend")}}</dt> + <dd>Fired when a <a href="/en-US/docs/CSS/Using_CSS_transitions">CSS transition</a> has completed.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontransitionend", "ontransitionend")}} property.</dd> + <dt>{{DOMxRef("Document/transitionrun_event", "transitionrun")}}</dt> + <dd>Fired when a <a href="/en-US/docs/CSS/Using_CSS_transitions">CSS transition</a> is first created.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontransitionrun", "ontransitionrun")}} property.</dd> + <dt>{{DOMxRef("Document/transitionstart_event", "transitionstart")}}</dt> + <dd>Fired when a <a href="/en-US/docs/CSS/Using_CSS_transitions">CSS transition</a> has actually started.<br> + Also available via the {{DOMxRef("GlobalEventHandlers/ontransitionstart", "ontransitionstart")}} property.</dd> +</dl> + +<h2 id="Non-standard_extensions_Non-standard_Inline">Non-standard extensions {{Non-standard_Inline}}</h2> + +<div>{{non-standard_header}}</div> + +<h3 id="Firefox_notes">Firefox notes</h3> + +<p>Mozilla defines a set of non-standard properties made only for XUL content:</p> + +<dl> + <dt>{{DOMxRef("Document.currentScript")}} {{Non-standard_Inline}}</dt> + <dd>Returns the {{HTMLElement("script")}} element that is currently executing.</dd> + <dt>{{DOMxRef("Document.documentURIObject")}}</dt> + <dd>(<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).</dd> + <dt>{{DOMxRef("Document.popupNode")}}</dt> + <dd>Returns the node upon which a popup was invoked.</dd> + <dt>{{DOMxRef("Document.tooltipNode")}}</dt> + <dd>Returns the node which is the target of the current tooltip.</dd> +</dl> + +<p>Mozilla also define some non-standard methods:</p> + +<dl> + <dt>{{DOMxRef("Document.execCommandShowHelp()")}}{{Obsolete_Inline("Gecko14")}}</dt> + <dd>This method never did anything and always threw an exception, so it was removed in Gecko 14.0 {{geckoRelease("14.0")}}.</dd> + <dt>{{DOMxRef("Document.getBoxObjectFor()")}} {{Obsolete_Inline}}</dt> + <dd>Use the {{DOMxRef("Element.getBoundingClientRect()")}} method instead.</dd> + <dt>{{DOMxRef("Document.loadOverlay()")}}{{Obsolete_Inline("Gecko61")}}</dt> + <dd>Loads a <a href="/en-US/docs/XUL_Overlays" title="XUL_Overlays">XUL overlay</a> dynamically. This only works in XUL documents.</dd> + <dt>{{DOMxRef("Document.queryCommandText()")}}{{Obsolete_Inline("Gecko14")}}</dt> + <dd>This method never did anything but throw an exception, and was removed in Gecko 14 {{GeckoRelease("14")}}.</dd> +</dl> + +<h3 id="Internet_Explorer_notes">Internet Explorer notes</h3> + +<p>Microsoft defines some non-standard properties:</p> + +<dl> + <dt>{{DOMxRef("Document.fileSize")}}* {{Non-standard_Inline}} {{Obsolete_Inline}}</dt> + <dd>Returns size in bytes of the document. Starting with Internet Explorer 11, that property is no longer supported. See <a href="http://msdn.microsoft.com/en-us/library/ms533752%28v=VS.85%29.aspx">MSDN</a>.</dd> +</dl> + +<p>Internet Explorer does not support all methods from the <code>Node</code> interface in the <code>Document</code> interface:</p> + +<dl> + <dt>{{DOMxRef("Document.contains")}}</dt> + <dd>As a work-around, <code>document.body.contains()</code> can be used.</dd> +</dl> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("DOM WHATWG", "#interface-document", "Document")}}</td> + <td>{{Spec2("DOM WHATWG")}}</td> + <td>Intend to supersede DOM 3</td> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "dom.html#the-document-object", "Document")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td>Turn the {{DOMxRef("HTMLDocument")}} interface into a <code>Document</code> extension.</td> + </tr> + <tr> + <td>{{SpecName("CSSOM View", "#extensions-to-the-document-interface", "Document")}}</td> + <td>{{Spec2("CSSOM View")}}</td> + <td>Extend the <code>Document</code> interface</td> + </tr> + <tr> + <td>{{SpecName("Pointer Lock", "#extensions-to-the-document-interface", "Document")}}</td> + <td>{{Spec2("Pointer Lock")}}</td> + <td>Extend the <code>Document</code> interface</td> + </tr> + <tr> + <td>{{SpecName("Page Visibility API", "#extensions-to-the-document-interface", "Document")}}</td> + <td>{{Spec2("Page Visibility API")}}</td> + <td>Extend the <code>Document</code> interface with the <code>visibilityState</code> and <code>hidden</code> attributes and the <code>onvisibilitychange</code> event listener.</td> + </tr> + <tr> + <td>{{SpecName("Selection API", "#extensions-to-document-interface", "Document")}}</td> + <td>{{Spec2("Selection API")}}</td> + <td>Adds <code>getSelection()</code>, <code>onselectstart</code> and <code>onselectionchange</code>.</td> + </tr> + <tr> + <td>{{SpecName("DOM4", "#interface-document", "Document")}}</td> + <td>{{Spec2("DOM4")}}</td> + <td>Supersede DOM 3</td> + </tr> + <tr> + <td>{{SpecName("DOM3 Core", "#i-Document", "Document")}}</td> + <td>{{Spec2("DOM3 Core")}}</td> + <td>Supersede DOM 2</td> + </tr> + <tr> + <td>{{SpecName("DOM3 XPath", "xpath.html#XPathEvaluator", "XPathEvaluator")}}</td> + <td>{{Spec2("DOM3 XPath")}}</td> + <td>Define the {{DOMxRef("XPathEvaluator")}} interface which extend document.</td> + </tr> + <tr> + <td>{{SpecName("DOM2 Core", "#i-Document", "Document")}}</td> + <td>{{Spec2("DOM2 Core")}}</td> + <td>Supersede DOM 1</td> + </tr> + <tr> + <td>{{SpecName("DOM1", "#i-Document", "Document")}}</td> + <td>{{Spec2("DOM1")}}</td> + <td>Initial definition for the interface</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.Document")}}</p> |