Document

@native @JSGlobal @JSType
abstract class Document extends Node with NodeSelector with DocumentEvent with ParentNode with PageVisibility

Each web page loaded in the browser has its own document object. The Document interface 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).

class Node
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Concrete methods

def adoptNode(source: Node): Node

Adopts a node from an external document. The node and its subtree is removed from the document it's in (if any), and its ownerDocument is changed to the current document. The node can then be inserted into the current document.

Adopts a node from an external document. The node and its subtree is removed from the document it's in (if any), and its ownerDocument is changed to the current document. The node can then be inserted into the current document.

def characterSet: String

Returns the character encoding of the current document.

Returns the character encoding of the current document.

def createAttribute(name: String): Attr

createAttribute creates a new attribute node, and returns it.

createAttribute creates a new attribute node, and returns it.

def createAttributeNS(namespaceURI: String, qualifiedName: String): Attr

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

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

def createCDATASection(data: String): CDATASection

createCDATASection() creates a new CDATA section node, and returns it.

createCDATASection() creates a new CDATA section node, and returns it.

def createComment(data: String): Comment

createComment() creates a new comment node, and returns it.

createComment() creates a new comment node, and returns it.

Creates a new empty DocumentFragment.

Creates a new empty DocumentFragment.

def createElement(tagName: String): Element

In an HTML document creates the specified HTML element or HTMLUnknownElement if the element is not known. In a XUL document creates the specified XUL element. In other documents creates an element with a null namespaceURI.

In an HTML document creates the specified HTML element or HTMLUnknownElement if the element is not known. In a XUL document creates the specified XUL element. In other documents creates an element with a null namespaceURI.

def createElementNS(namespaceURI: String, qualifiedName: String): Element

Creates an element with the specified namespace URI and qualified name.

Creates an element with the specified namespace URI and qualified name.

Creates an XPathNSResolver which resolves namespaces with respect to the definitions in scope for a specified node.

Creates an XPathNSResolver which resolves namespaces with respect to the definitions in scope for a specified node.

def createNodeIterator(root: Node, whatToShow: Int, filter: NodeFilter, entityReferenceExpansion: Boolean): NodeIterator

Supported in FF 3.5+, Chrome 1+, Opera 9+, Safari 3+, IE9+

Supported in FF 3.5+, Chrome 1+, Opera 9+, Safari 3+, IE9+

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

createProcessingInstruction() creates a new processing instruction node, and returns it.

createProcessingInstruction() creates a new processing instruction node, and returns it.

Once a Range is created, you need to set its boundary points before you can make use of most of its methods.

Once a Range is created, you need to set its boundary points before you can make use of most of its methods.

def createStyleSheet(href: String, index: Int): CSSStyleSheet
def createTextNode(data: String): Text
def createTreeWalker(root: Node, whatToShow: Int, filter: NodeFilter, entityReferenceExpansion: Boolean): TreeWalker

The Document.createTreeWalker() creator method returns a newly created TreeWalker object.

The Document.createTreeWalker() creator method returns a newly created TreeWalker object.

Returns the Document Type Declaration (DTD) associated with current document. The returned object implements the DocumentType interface. Use DOMImplementation.createDocumentType() to create a DocumentType.

Returns the Document Type Declaration (DTD) associated with current document. The returned object implements the DocumentType interface. Use DOMImplementation.createDocumentType() to create a DocumentType.

Returns the Element that is the root element of the document (for example, the <html> element for HTML documents).

Returns the Element that is the root element of the document (for example, the <html> element for HTML documents).

def documentURI: String
def elementFromPoint(x: Double, y: Double): Element

Returns the element from the document whose elementFromPoint method is being called which is the topmost element which lies under the given point.  To get an element, specify the point via coordinates, in CSS pixels, relative to the upper-left-most point in the window or frame containing the document.

Returns the element from the document whose elementFromPoint method is being called which is the topmost element which lies under the given point.  To get an element, specify the point via coordinates, in CSS pixels, relative to the upper-left-most point in the window or frame containing the document.

def evaluate(xpathExpression: String, contextNode: Node, namespaceResolver: XPathNSResolver, resultType: Int, result: XPathResult): XPathResult

Returns an XPathResult based on an XPath expression and other given parameters.

Returns an XPathResult based on an XPath expression and other given parameters.

Value parameters:
contextNode

specifies the context node for the query (see the http://www.w3.org/TR/xpath XPath specification). It's common to pass document as the context node.

namespaceResolver

an XPathNSResolver

result

is an existing XPathResult to use for the results. null is the most common and will create a new XPathResult

resultType

is an integer that corresponds to the type of result XPathResult to return. Use named constant properties, such as XPathResult.ANY_TYPE, of the XPathResult constructor, which correspond to integers from 0 to 9.

xpathExpression

is a string representing the XPath to be evaluated.

def evaluate(xpathExpression: String, contextNode: Node, namespaceResolver: Function1[String, String], resultType: Int, result: XPathResult): XPathResult

Returns an XPathResult based on an XPath expression and other given parameters.

Returns an XPathResult based on an XPath expression and other given parameters.

Value parameters:
contextNode

specifies the context node for the query (see the [http://www.w3.org/TR/xpath XPath specification). It's common to pass document as the context node.

namespaceResolver

is a function that will be passed any namespace prefixes and should return a string representing the namespace URI associated with that prefix. It will be used to resolve prefixes within the XPath itself, so that they can be matched with the document. null is common for HTML documents or when no namespace prefixes are used.

result

is an existing XPathResult to use for the results. null is the most common and will create a new XPathResult

resultType

is an integer that corresponds to the type of result XPathResult to return. Use named constant properties, such as XPathResult.ANY_TYPE, of the XPathResult constructor, which correspond to integers from 0 to 9.

xpathExpression

is a string representing the XPath to be evaluated.

def exitFullscreen(): Promise[Unit]

The Document method exitFullscreen() requests that the element on this document which is currently being presented in full-screen mode be taken out of full-screen mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to Element.requestFullscreen().

The Document method exitFullscreen() requests that the element on this document which is currently being presented in full-screen mode be taken out of full-screen mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to Element.requestFullscreen().

The exception is if another element was already in full-screen mode when the current element was placed into full-screen mode using requestFullscreen(). In that case, the previous full-screen element is restored to full-screen status instead. In essence, a stack of full-screen elements is maintained.

def exitPointerLock(): Unit

The exitPointerLock asynchronously releases a pointer lock previously requested through Element.requestPointerLock.

The exitPointerLock asynchronously releases a pointer lock previously requested through Element.requestPointerLock.

To track the success or failure of the request, it is necessary to listen for the pointerlockchange and pointerlockerror events.

The DocumentOrShadowRoot.fullscreenElement read-only property returns the Element that is currently being presented in full-screen mode in this document, or null if full-screen mode is not currently in use.

The DocumentOrShadowRoot.fullscreenElement read-only property returns the Element that is currently being presented in full-screen mode in this document, or null if full-screen mode is not currently in use.

Although this property is read-only, it will not throw if it is modified (even in strict mode); the setter is a no-operation and it will be ignored.

def fullscreenEnabled: Boolean

The read-only fullscreenEnabled property on the Document interface indicates whether or not full-screen mode is available. Full-screen mode is available only for a page that has no windowed plug-ins in any of its documents, and if all