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.HTMLElement

Documentation Document by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Constructor

new()

Throws:

null

DOMError

Variables

read onlyURL:String

Returns the document location as a string.

read onlyanchors:HTMLCollection

Returns a list of all of the anchors in the document.

read onlyapplets:HTMLCollection

Returns an ordered list of the applets within a document.

body:Element

Returns the body or frameset node of the current document.

read onlycharacterSet:String

Returns the character set being used by the document.

read onlycharset:String

Alias of Document.characterSet. Use this property instead.

read onlycompatMode:String

Indicates whether the document is rendered in quirks or strict mode.

read onlycontentType:String

Returns the Content-Type from the MIME Header of the current document.

read onlydefaultView:Window

Returns a reference to the window object.

dir:String

Gets/sets directionality (rtl/ltr) of the document.

read onlydoctype:DocumentType

Returns the Document Type Definition (DTD) of the current document.

read onlydocumentElement:Element

Returns the Element that is a direct child of the document. For HTML documents, this is normally the HTMLElement element.

read onlydocumentURI:String

Returns the document location as a string.

read onlyembeds:HTMLCollection

Returns a list of the embedded embed elements within the current document.

read onlyforms:HTMLCollection

Returns a list of the form elements within the current document.

read onlyfullscreen:Bool

true when the document is in Using_full-screen_mode.

read onlyfullscreenElement:Element

The element that's currently in full screen mode for this document.

read onlyhead:HeadElement

Returns the head element of the current document.

read onlyhidden:Bool

read onlyimages:HTMLCollection

Returns a list of the images in the current document.

read onlyimplementation:DOMImplementation

Returns the DOM implementation associated with the current document.

read onlyinputEncoding:String

Alias of Document.characterSet. Use this property instead.

read onlylastModified:String

Returns the date on which the document was last modified.

read onlylastStyleSheetSet:String

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 document.selectedStyleSheetSet.

read onlylinks:HTMLCollection

Returns a list of all the hyperlinks in the document.

read onlylocation:Location

Returns the URI of the current document.

onafterscriptexecute:Function

Represents the event handling code for the afterscriptexecute event.

onbeforescriptexecute:Function

Represents the event handling code for the beforescriptexecute event.

oncopy:Function

Represents the event handling code for the copy event.

oncut:Function

Represents the event handling code for the cut event.

onfullscreenchange:Function

Is an EventHandler representing the code to be called when the fullscreenchange event is raised.

onfullscreenerror:Function

Is an EventHandler representing the code to be called when the fullscreenerror event is raised.

onpaste:Function

Represents the event handling code for the paste event.

onpointerlockchange:Function

Represents the event handling code for the pointerlockchange event.

onpointerlockerror:Function

Represents the event handling code for the pointerlockerror event.

onreadystatechange:Function

Represents the event handling code for the readystatechange event.

onselectionchange:Function

Is an EventHandler representing the code to be called when the selectionchange event is raised.

onvisibilitychange:Function

Is an EventHandler representing the code to be called when the visibilitychange event is raised.

onwheel:Function

Represents the event handling code for the wheel event.

read onlyplugins:HTMLCollection

Returns a list of the available plugins.

read onlypreferredStyleSheetSet:String

Returns the preferred style sheet set as specified by the page author.

read onlyreadyState:String

Returns loading status of the document.

read onlyreferrer:String

Returns the URI of the page that linked to this page.

read onlyscripts:HTMLCollection

Returns all the script elements on the document.

read onlyscrollingElement:Element

Returns a reference to the Element that scrolls the document.

selectedStyleSheetSet:String

Returns which style sheet set is currently in use.

read onlystyleSheetSets:DOMStringList

Returns a list of the style sheet sets available on the document.

title:String

Sets or gets the title of the current document.

read onlyvisibilityState:VisibilityState

Returns a string denoting the visibility state of the document. Possible values are visiblehiddenprerender, and unloaded.

Methods

adoptNode(node:Node):Node

Adopt node from an external document.

Throws:

null

DOMError

append(nodes:Rest<Node>):Void

append(nodes:Rest<String>):Void

Throws:

null

DOMError

createAttribute(name:String):Attr

Creates a new Attr object and returns it.

Throws:

null

DOMError

createAttributeNS(namespace:String, name:String):Attr

Creates a new attribute node in a given namespace and returns it.

Throws:

null

DOMError

createCDATASection(data:String):CDATASection

Creates a new CDATA node and returns it.

Throws:

null

DOMError

createComment(data:String):Comment

Creates a new comment node and returns it.

createDocumentFragment():DocumentFragment

Creates a new document fragment.

createElement(localName:String, ?options:Null<ElementCreationOptions>):Element

createElement(localName:String, ?options:String):Element

Creates a new element with the given tag name.

Throws:

null

DOMError

createElementNS(namespace:String, qualifiedName:String, ?options:Null<ElementCreationOptions>):Element

createElementNS(namespace:String, qualifiedName:String, ?options:String):Element

Creates a new element with the given tag name and namespace URI.

Throws:

null

DOMError

createEvent(interface_:String):Event

Creates an event object.

Throws:

null

DOMError

createExpression(expression:String, ?resolver:String ‑> Null<String>):XPathExpression

createExpression(expression:String, ?resolver:Function):XPathExpression

createExpression(expression:String, ?resolver:Null<XPathNSResolver>):XPathExpression

Throws:

null

DOMError

createNSResolver(nodeResolver:Node):Node

@:value({ whatToShow : cast 4294967295 })createNodeIterator(root:Node, whatToShow:Int = cast 4294967295, ?filter:Node ‑> Int):NodeIterator

@:value({ whatToShow : cast 4294967295 })createNodeIterator(root:Node, whatToShow:Int = cast 4294967295, ?filter:Function):NodeIterator

@:value({ whatToShow : cast 4294967295 })createNodeIterator(root:Node, whatToShow:Int = cast 4294967295, ?filter:NodeFilter):NodeIterator

Creates a NodeIterator object.

Throws:

null

DOMError

createProcessingInstruction(target:String, data:String):ProcessingInstruction

Creates a new ProcessingInstruction object.

Throws:

null

DOMError

createRange():Range

Creates a Range object.

Throws:

null

DOMError

createTextNode(data:String):Text

Creates a text node.

@:value({ force : 0.0, rotationAngle : 0.0, radiusY : 0, radiusX : 0, clientY : 0, clientX : 0, screenY : 0, screenX : 0, pageY : 0, pageX : 0, identifier : 0 })createTouch(?view:Window, ?target:EventTarget, identifier:Int = 0, pageX:Int = 0, pageY:Int = 0, screenX:Int = 0, screenY:Int = 0, clientX:Int = 0, clientY:Int = 0, radiusX:Int = 0, radiusY:Int = 0, rotationAngle:Float = 0.0, force:Float = 0.0):Touch

Creates a Touch object.

@:value({ whatToShow : cast 4294967295 })createTreeWalker(root:Node, whatToShow:Int = cast 4294967295, ?filter:Node ‑> Int):TreeWalker

@:value({ whatToShow : cast 4294967295 })createTreeWalker(root:Node, whatToShow:Int = cast 4294967295, ?filter:Function):TreeWalker

@:value({ whatToShow : cast 4294967295 })createTreeWalker(root:Node, whatToShow:Int = cast 4294967295, ?filter:NodeFilter):TreeWalker

Creates a TreeWalker object.

Throws:

null

DOMError

enableStyleSheetsForSet(name:String):Void

Enables the style sheets for the specified style sheet set.

@:value({ type : 0 })evaluate(expression:String, contextNode:Node, ?resolver:String ‑> Null<String>, type:Int = 0, ?result:Dynamic):XPathResult

@:value({ type : 0 })evaluate(expression:String, contextNode:Node, ?resolver:Function, type:Int = 0, ?result:Dynamic):XPathResult

@:value({ type : 0 })evaluate(expression:String, contextNode:Node, ?resolver:Null<XPathNSResolver>, type:Int = 0, ?result:Dynamic):XPathResult

Throws:

null

DOMError

exitPointerLock():Void

Release the pointer lock.

getAnimations():Array<Animation>

Returns an array of all Animation objects currently in effect, whose target elements are descendants of the document.

getElementsByClassName(classNames:String):HTMLCollection

Returns a list of elements with the given class name.

getElementsByTagName(localName:String):HTMLCollection

Returns a list of elements with the given tag name.

getElementsByTagNameNS(namespace:String, localName:String):HTMLCollection

Returns a list of elements with the given tag name and namespace.

Throws:

null

DOMError

getSelection():Selection

Throws:

null

DOMError

hasFocus():Bool

Returns true if the focus is currently located anywhere inside the specified document.

Throws:

null

DOMError

@:value({ deep : false })importNode(node:Node, deep:Bool = false):Node

Returns a clone of a node from an external document.

Throws:

null

DOMError

prepend(nodes:Rest<Node>):Void

prepend(nodes:Rest<String>):Void

Throws:

null

DOMError

querySelector(selectors:String):Element

Throws:

null

DOMError

querySelectorAll(selectors:String):NodeList

Throws:

null

DOMError

releaseCapture():Void

Releases the current mouse capture if it's on an element in this document.

Inherited Variables

Defined by Node

read onlybaseURI:String

Returns a DOMString representing the base URL. The concept of base URL changes from one language to another; in HTML, it corresponds to the protocol, the domain name and the directory structure, that is all until the last '/'.

read onlychildNodes:NodeList

Returns a live NodeList containing all the children of this node. NodeList being live means that if the children of the Node change, the NodeList object is automatically updated.

read onlyfirstChild:Node

Returns a Node representing the first direct child node of the node, or null if the node has no child.

read onlyisConnected:Bool

Returns a boolean indicating whether or not the Node is connected (directly or indirectly) to the context object, e.g. the Document object in the case of the normal DOM, or the ShadowRoot in the case of a shadow DOM.

read onlylastChild:Node

Returns a Node representing the last direct child node of the node, or null if the node has no child.

read onlynextSibling:Node

Returns a Node representing the next node in the tree, or null if there isn't such node.

read onlynodeName:String

Returns a DOMString containing the name of the Node. The structure of the name will differ with the node type. E.g. An HTMLElement will contain the name of the corresponding tag, like 'audio' for an HTMLAudioElement, a Text node will have the '#text' string, or a Document node will have the '#document' string.

read onlynodeType:Int

Returns an unsigned short representing the type of the node. Possible values are:

Name Value

ELEMENT_NODE 1
ATTRIBUTE_NODE (deprecated) 2
TEXT_NODE 3
CDATA_SECTION_NODE (deprecated) 4
ENTITY_REFERENCE_NODE (deprecated) 5
ENTITY_NODE (deprecated) 6
PROCESSING_INSTRUCTION_NODE 7
COMMENT_NODE 8
DOCUMENT_NODE 9
DOCUMENT_TYPE_NODE 10
DOCUMENT_FRAGMENT_NODE 11
NOTATION_NODE (deprecated) 12

nodeValue:String

Returns / Sets the value of the current node

read onlyownerDocument:HTMLDocument

Returns the Document that this node belongs to. If the node is itself a document, returns null.

read onlyparentElement:Element

Returns an Element that is the parent of this node. If the node has no parent, or if that parent is not an Element, this property returns null.

read onlyparentNode:Node

Returns a Node that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.

read onlypreviousSibling:Node

Returns a Node representing the previous node in the tree, or null if there isn't such node.

textContent:String

Returns / Sets the textual content of an element and all its descendants.

Inherited Methods

Defined by Node

appendChild(node:Node):Node

Adds the specified childNode argument as the last child to the current node.

If the argument referenced an existing node on the DOM tree, the node will be detached from its current position and attached at the new position.

	@throws DOMError

@:value({ deep : false })cloneNode(deep:Bool = false):Node

Clone a Node, and optionally, all of its contents. By default, it clones the content of the node.

Throws:

null

DOMError

compareDocumentPosition(other:Node):Int

Compares the position of the current node against another node in any other document.

contains(other:Node):Bool

Returns a Boolean value indicating whether a node is a descendant of a given node or not.

getRootNode(?options:Null<GetRootNodeOptions>):Node

Returns the context object's root which optionally includes the shadow root if it is available. 

hasChildNodes():Bool

Returns a Boolean indicating if the element has any child nodes, or not.

insertBefore(node:Node, child:Node):Node

Inserts a Node before the reference node as a child of a specified parent node.

Throws:

null

DOMError

isDefaultNamespace(namespace:String):Bool

Accepts a namespace URI as an argument and returns a Boolean with a value of true if the namespace is the default namespace on the given node or false if not.

isEqualNode(node:Node):Bool

Returns a Boolean which indicates whether or not two nodes are of the same type and all their defining data points match.

isSameNode(node:Node):Bool

Returns a Boolean value indicating whether or not the two nodes are the same (that is, they reference the same object).

lookupNamespaceURI(prefix:String):String

Accepts a prefix and returns the namespace URI associated with it on the given node if found (and null if not). Supplying null for the prefix will return the default namespace.

lookupPrefix(namespace:String):String

Returns a DOMString containing the prefix for a given namespace URI, if present, and null if not. When multiple prefixes are possible, the result is implementation-dependent.

normalize():Void

Clean up all the text nodes under this element (merge adjacent, remove empty).

removeChild(child:Node):Node

Removes a child node from the current element, which must be a child of the current node.

Throws:

null

DOMError

replaceChild(node:Node, child:Node):Node

Replaces one child Node of the current one with the second one given in parameter.

Throws:

null

DOMError

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError