Table of Contents

Class Document

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

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.

[Value("Document")]
public class Document : Node
Inheritance
Document
Derived
Inherited Members

Remarks

The DOM tree includes elements such as body and table, among many others. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document.

The Document interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g., HTML, XML, SVG, …), a larger API is available: HTML documents, served with the "text/html" content type, also implement the HTMLDocument interface, whereas XML and SVG documents implement the XMLDocument interface.

See also on MDN

Constructors

Document()

The Document constructor creates a new
Document object that is a web page loaded in the browser and serving as
an entry point into the page's content.

public Document()

Remarks

Properties

AlinkColor

IMPORTANT
Deprecated
Returns or sets the color of an active link in the document body. A link is active
during the time between mousedown and mouseup events.
[Value("alinkColor")]
public string AlinkColor { get; set; }

Property Value

string

A string containing the name of the color (e.g., blue, darkblue, etc.) or the hexadecimal value of the color (e.g., #0000FF).When set to the null value, that null value is converted to the empty string (""), so document.alinkColor = null is equivalent to document.alinkColor = "".

Remarks

All

IMPORTANT
Deprecated
The Document interface's read-only all property returns an HTMLAllCollection rooted at the document node.
[Value("all")]
public HTMLAllCollection All { get; }

Property Value

HTMLAllCollection

An HTMLAllCollection which contains every element in the document.

Remarks

Rather than using document.all to return an HTMLAllCollection of all the document's elements in document order, you can use Document.QuerySelectorAll to return a NodeList of all the document's elements in document order:

See also on MDN

Anchors

IMPORTANT
Deprecated
The anchors read-only property of the
Document interface returns a list of all of the anchors in the document.
[Value("anchors")]
public HTMLCollection Anchors { get; }

Property Value

HTMLCollection

An HTMLCollection.

Remarks

Applets

IMPORTANT
Deprecated
The applets property of the Document returns an empty HTMLCollection. This property is kept only for compatibility reasons; in older versions of browsers, it returned a list of the applets within a document.
[Value("applets")]
public HTMLCollection Applets { get; }

Property Value

HTMLCollection

An empty HTMLCollection.

Remarks

NOTE

Support for the <applet> element has been removed by all browsers. Therefore, calling document.applets always
returns an empty collection.

See also on MDN

BgColor

IMPORTANT
Deprecated
The deprecated bgColor property gets or sets the background color of the
current document.
[Value("bgColor")]
public string BgColor { get; set; }

Property Value

string

A string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").When set to the null value, that null value is converted to the empty string (""), so document.bgColor = null is equivalent to document.bgColor = "".

Remarks

Body

The Document.body property represents the
body or frameset node of the current document, or
null if no such element exists.

[Value("body")]
public HTMLElement? Body { get; set; }

Property Value

HTMLElement

One of the following:

Remarks

CharacterSet

The Document.characterSet
read-only property returns the character encoding of the
document that it's currently rendered with.

[Value("characterSet")]
public string CharacterSet { get; }

Property Value

string

A string.

Remarks

NOTE

A "character set" and a "character encoding" are related, but different. Despite the
name of this property, it returns the encoding.

See also on MDN

Charset

[Value("charset")]
public string Charset { get; }

Property Value

string

CompatMode

The Document.compatMode read-only property indicates
whether the document is rendered in Quirks mode or
Standards mode.

[Value("compatMode")]
public string CompatMode { get; }

Property Value

string

A string that is one of the following:

NOTE
All these modes are now standardized, so the older "standards"
and "almost standards" names are nonsensical and no longer used in standards.

Remarks

ContentType

The Document.contentType read-only property returns the
MIME type that the document is being rendered as. This may come from HTTP headers or
other sources of MIME information, and might be affected by automatic type conversions
performed by either the browser or extensions.

[Value("contentType")]
public string ContentType { get; }

Property Value

string

contentType is a read-only property.

Remarks

NOTE

This property is unaffected by meta
elements.

See also on MDN

The Document property cookie lets you read and write cookies associated with the document.
It serves as a getter and setter for the actual values of the cookies.

[Value("cookie")]
public string Cookie { get; set; }

Property Value

string

A string containing a semicolon-separated list of all cookies (i.e., key=value pairs).
Note that each key and value may be surrounded by whitespace (space and tab characters): in fact, {{RFC(6265)}} mandates a single space after each semicolon, but some user agents may not abide by this.You can also assign to this property a string of the form "key=value", specifying the cookie to set/update. Note that you can only set/update a single cookie at a time using this method. Consider also that:

NOTE
The document.cookie property is an accessor property with native setter and getter functions, and consequently is not a data property with a value: what you write is not the same as what you read, everything is always mediated by the JavaScript interpreter.

CurrentScript

The Document.currentScript property returns the script element whose script is currently being processed and isn't a JavaScript module. (For modules use import.meta instead.)

[Value("currentScript")]
public Union56? CurrentScript { get; }

Property Value

Union56?

A HTMLScriptElement or null.

Remarks

It's important to note that this will not reference the script
element if the code in the script is being called as a callback or event handler; it
will only reference the element while it's initially being processed.

-import.meta
-script
-Document.Afterscriptexecute event of Document
-Document.Beforescriptexecute event of Document

See also on MDN

DefaultView

In browsers, document.defaultView returns the
Window object associated with {{Glossary("Browsing_context", "a document")}}, or null if none is available.

[Value("defaultView")]
public Window? DefaultView { get; }

Property Value

Window

The Window object.

Remarks

This property is read-only.

See also on MDN

DesignMode

document.designMode controls whether the entire document
is editable. Valid values are "on" and "off". According to the
specification, this property is meant to default to "off". Firefox follows
this standard. The earlier versions of Chrome and IE default to "inherit".
Starting in Chrome 43, the default is "off" and "inherit" is
no longer supported. In IE6-10, the value is capitalized.

[Value("designMode")]
public string DesignMode { get; set; }

Property Value

string

A string indicating whether designMode is (or should be) set to on or off.
Valid values are on and off.

Remarks

-HTMLElement.ContentEditable

See also on MDN

Dir

The Document.dir property is a string
representing the directionality of the text of the document, whether left to right
(default) or right to left. Possible values are 'rtl', right to left, and
'ltr', left to right.

[Value("dir")]
public string Dir { get; set; }

Property Value

string

A string.

Remarks

-dir global
attribute

See also on MDN

Doctype

The doctype read-only property of the Document interface is a DocumentType object representing the {{glossary("Doctype", "Document Type Declaration (DTD)")}} associated with the current document.

[Value("doctype")]
public DocumentType? Doctype { get; }

Property Value

DocumentType

A DocumentType object.

Remarks

DocumentElement

The documentElement read-only property of the Document interface returns the
Element that is the root element of the Document (for
example, the html element for HTML documents).

[Value("documentElement")]
public Element? DocumentElement { get; }

Property Value

Element

A Element object.

Remarks

DocumentURI

The documentURI read-only property of the
Document interface returns the document location as a string.

[Value("documentURI")]
public string DocumentURI { get; }

Property Value

string

A string.

Remarks

-The URL property which returns the same value.

See also on MDN

Domain

IMPORTANT
Deprecated
The domain property of the Document
interface gets/sets the domain portion of the origin of the current
document, as used by the same-origin policy.
[Value("domain")]
public string Domain { get; set; }

Property Value

string

A string.

Remarks

Embeds

The embeds read-only property of the
Document interface returns a list of the embedded
embed elements within the current document.

[Value("embeds")]
public HTMLCollection Embeds { get; }

Property Value

HTMLCollection

An HTMLCollection.

Remarks

FgColor

IMPORTANT
Deprecated
fgColor gets/sets the foreground color, or text color, of
the current document.
[Value("fgColor")]
public string FgColor { get; set; }

Property Value

string

A string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").

Remarks

Forms

The forms read-only property of the Document interface returns an HTMLCollection listing all the {{HTMLElement("form")}} elements contained in the document.

[Value("forms")]
public HTMLCollection Forms { get; }

Property Value

HTMLCollection

An HTMLCollection object listing all of the document's forms.
Each item in the collection is a HTMLFormElement representing a single <form> element.If the document has no forms, the returned collection is empty, with a length of zero.

Remarks

NOTE

Similarly, you can access a list of a form's component user input elements using the Elements property.

You can also access named <form> elements as properties of the document object.
For example, document["login-form"] and document.forms["login-form"] can both be used to access the form named login-form.

WARNING

Relying on the document["form-name"] pattern is dangerous and discouraged because it can lead to unexpected conflicts with existing or future APIs in the browser.
For example, if a browser introduces a built-in document["login-form"] property in the future, your code may no longer be able to access the form element.
To avoid such conflicts, always use document.forms to access named forms.

-HTML forms
-{{HTMLElement("form")}} and the HTMLFormElement interface

See also on MDN

FragmentDirective

The fragmentDirective read-only property of the Document interface returns the FragmentDirective for the current document.

[Value("fragmentDirective")]
public FragmentDirective FragmentDirective { get; }

Property Value

FragmentDirective

A FragmentDirective object.

Remarks

-Text fragments
-{{cssxref("::target-text")}}

See also on MDN

Fullscreen

IMPORTANT
Deprecated
The obsolete Document interface's fullscreen read-only property reports whether or not the document is currently displaying content in fullscreen mode.
[Value("fullscreen")]
public bool Fullscreen { get; }

Property Value

bool

A Boolean value which is true if the document is currently displaying an element in fullscreen mode; otherwise, the value is false.

Remarks

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.

NOTE

Since this property is deprecated, you can determine if fullscreen mode is active on the document by checking to see if Document.FullscreenElement is not null.

-Fullscreen API
-Guide to the Fullscreen API
-FullscreenEnabled

See also on MDN

FullscreenEnabled

The read-only fullscreenEnabled
property on the Document interface indicates whether or not fullscreen
mode is available.

[Value("fullscreenEnabled")]
public bool FullscreenEnabled { get; }

Property Value

bool

A boolean value which is true if the document and the
elements within can be placed into fullscreen mode by calling
RequestFullscreen(FullscreenOptions). If fullscreen mode isn't available, this
value is false.

Remarks

fullscreen mode is available only for a page that has no
windowed plug-ins in any of its documents, and if all iframe elements
which contain the document have their allowfullscreen
attribute set.

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.

-Fullscreen API
-Guide to the Fullscreen API
-RequestFullscreen(FullscreenOptions)
-ExitFullscreen()
-Document.FullscreenElement
-:fullscreen and {{cssxref("::backdrop")}}
-The iframe allowfullscreen
attribute

See also on MDN

Head

The head read-only property of
the Document interface returns the {{HTMLElement("head")}} element of
the current document.

[Value("head")]
public HTMLHeadElement? Head { get; }

Property Value

HTMLHeadElement

An HTMLHeadElement.

Remarks

Hidden

The Document.hidden read-only property returns a Boolean
value indicating if the page is considered hidden or not.

[Value("hidden")]
public bool Hidden { get; }

Property Value

bool

A Boolean value, true if the page is hidden, and false otherwise.

Remarks

The VisibilityState property provides an alternative way to determine whether the page is hidden.

-VisibilityState

See also on MDN

Images

The images read-only property of the Document interface returns a collection of the images in the current HTML document.

[Value("images")]
public HTMLCollection Images { get; }

Property Value

HTMLCollection

An HTMLCollection providing a live list of all of the images contained in the current document.
Each entry in the collection is an HTMLImageElement representing a single image element.

Remarks

Implementation

The Document.implementation property returns a
DOMImplementation object associated with the current document.

[Value("implementation")]
public DOMImplementation Implementation { get; }

Property Value

DOMImplementation

A DOMImplementation object.

Remarks

InputEncoding

[Value("inputEncoding")]
public string InputEncoding { get; }

Property Value

string

LastModified

The lastModified property of the Document
interface returns a string containing the date and local time on which the current document
was last modified.

[Value("lastModified")]
public string LastModified { get; }

Property Value

string

A string.

Remarks

LinkColor

IMPORTANT
Deprecated
The Document.linkColor property gets/sets the color of
links within the document.
[Value("linkColor")]
public string LinkColor { get; set; }

Property Value

string

A string representing the color as a word (e.g., red) or hexadecimal value (e.g., #ff0000).When set to the null value, that null value is converted to the empty string (""), so document.linkColor = null is equivalent to document.linkColor = "".

Remarks

This property is deprecated. As an alternative, you can set the CSS
{{cssxref("color")}} property on either HTML anchor links (a) or on
:link pseudo-classes.

-VlinkColor
-AlinkColor

See also on MDN

The links read-only property of the Document interface returns a collection of all {{HTMLElement("area")}} elements and {{HTMLElement("a")}} elements in a document with a value for the href attribute.

[Value("links")]
public HTMLCollection Links { get; }

Property Value

HTMLCollection

An HTMLCollection.

Location

The Document.location read-only property returns a
Location object, which contains information about the URL of the document
and provides methods for changing that URL and loading another URL.

[Value("location")]
public Location? Location { get; }

Property Value

Location

A Location object.

Remarks

Though Document.location is a read-only Location
object, you can also assign a string to it. This means that you can
work with document.location as if it were a string in most cases:
document.location = 'http://www.example.com' is a synonym of
document.location.href = 'http://www.example.com'. If you assign another
string to it, browser will load the website you assigned.

To retrieve just the URL as a string, the read-only URL
property can also be used.

If the current document is not in a browsing context, the returned value is
null.

-The interface of the returned value, Location
-A similar information, but attached to the browsing context,
Location

See also on MDN

NamedFlows

[Value("namedFlows")]
public NamedFlowMap NamedFlows { get; }

Property Value

NamedFlowMap

Onfreeze

[Value("onfreeze")]
public EventHandlerNonNull Onfreeze { get; set; }

Property Value

EventHandlerNonNull

Onfullscreenchange

[Value("onfullscreenchange")]
public EventHandlerNonNull Onfullscreenchange { get; set; }

Property Value

EventHandlerNonNull

Onfullscreenerror

[Value("onfullscreenerror")]
public EventHandlerNonNull Onfullscreenerror { get; set; }

Property Value

EventHandlerNonNull

Onpointerlockchange

[Value("onpointerlockchange")]
public EventHandlerNonNull Onpointerlockchange { get; set; }

Property Value

EventHandlerNonNull

Onpointerlockerror

[Value("onpointerlockerror")]
public EventHandlerNonNull Onpointerlockerror { get; set; }

Property Value

EventHandlerNonNull

Onprerenderingchange

[Value("onprerenderingchange")]
public EventHandlerNonNull Onprerenderingchange { get; set; }

Property Value

EventHandlerNonNull

Onreadystatechange

[Value("onreadystatechange")]
public EventHandlerNonNull Onreadystatechange { get; set; }

Property Value

EventHandlerNonNull

Onresume

[Value("onresume")]
public EventHandlerNonNull Onresume { get; set; }

Property Value

EventHandlerNonNull

Onvisibilitychange

[Value("onvisibilitychange")]
public EventHandlerNonNull Onvisibilitychange { get; set; }

Property Value

EventHandlerNonNull

PermissionsPolicy

[Value("permissionsPolicy")]
public PermissionsPolicy PermissionsPolicy { get; }

Property Value

PermissionsPolicy

PictureInPictureEnabled

The read-only
pictureInPictureEnabled property of the
Document interface indicates whether or not picture-in-picture mode is
available.

[Value("pictureInPictureEnabled")]
public bool PictureInPictureEnabled { get; }

Property Value

bool

A boolean value, which is true if a video can enter
picture-in-picture and be displayed in a floating window by calling
RequestPictureInPicture(). If picture-in-picture mode isn't
available, this value is false.

Remarks

Picture-in-Picture mode is available by default unless specified
otherwise by a Permissions-Policy.

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 will be ignored.

-RequestPictureInPicture()
-DisablePictureInPicture
-ExitPictureInPicture()
-Document.PictureInPictureElement
-:picture-in-picture

See also on MDN

Plugins

The plugins read-only property of the
Document interface returns an HTMLCollection object
containing one or more HTMLEmbedElements representing the
embed elements in the current document.

[Value("plugins")]
public HTMLCollection Plugins { get; }

Property Value

HTMLCollection

An HTMLCollection.

Remarks

NOTE

For a list of installed plugins, use Navigator.plugins
instead.

See also on MDN

Prerendering

CAUTION
Non-standard
The prerendering read-only property of the Document interface returns true if the document is currently in the process of prerendering, as initiated via the Speculation Rules API.
[Value("prerendering")]
public bool Prerendering { get; }

Property Value

bool

A boolean. Returns true if the document is currently in the process of prerendering, and false if it is not. false will be returned for documents that have finished prerendering, and documents that were not prerendered.

Remarks

-Speculation Rules API
-Document.Prerenderingchange event
-ActivationStart property

See also on MDN

ReadyState

The Document.readyState property describes the loading state of the Document.
When the value of this property changes, a Documentreadystatechange event fires on the Document object.

[Value("readyState")]
public DocumentReadyState ReadyState { get; }

Property Value

DocumentReadyState

The readyState of a document can be one of following:

Remarks

-Related events:-Documentreadystatechange
-DocumentDOMContentLoaded
-Windowload

See also on MDN

Referrer

The Document.referrer property returns the URI of the page that linked to
this page.

[Value("referrer")]
public string Referrer { get; }

Property Value

string

The value is an empty string if the user navigated to the page directly (not through a
link, but, for example, by using a bookmark). Because this property returns only a
string, it doesn't give you document object model (DOM) access to the referring page.Inside an iframe, the Document.referrer will initially
be set to the HTMLAnchorElementhref of the parent's
Windowlocation in same-origin requests.
In cross-origin requests, it's the HTMLAnchorElementorigin of the parent's Window.location by default.
For more information, see the Referrer-Policy: strict-origin-when-cross-origin documentation.

Remarks

RootElement

IMPORTANT
Deprecated
Document.rootElement returns the Element
that is the root element of the Document if it is an
svg element, otherwise null. It is deprecated in favor of
DocumentElement, which returns the root element for all
documents.
[Value("rootElement")]
public SVGSVGElement? RootElement { get; }

Property Value

SVGSVGElement

For SVG elements, the Element that is the root element of the Document; otherwise null.If the document is a non-empty SVG document, then the rootElement will be
an SVGSVGElement, identical to the documentElement.

Remarks

Scripts

The scripts property of the Document
interface returns a list of the script
elements in the document. The returned object is an
HTMLCollection.

[Value("scripts")]
public HTMLCollection Scripts { get; }

Property Value

HTMLCollection

An HTMLCollection. You can use this just like an array to get all the
elements in the list.

Remarks

ScrollingElement

The scrollingElement read-only property of the
Document interface returns a reference to the Element that
scrolls the document. In standards mode, this is the root element of the
document, DocumentElement.

[Value("scrollingElement")]
public Element? ScrollingElement { get; }

Property Value

Element

The Element that scrolls the document, usually the root element (unless not in standard mode).

Remarks

When in quirks mode, the scrollingElement attribute returns the HTML
body element if it exists and is not potentially scrollable, otherwise it returns null. This may look surprising but is true according to both the specification and browsers.

See also on MDN

Timeline

The timeline readonly property of the Document interface represents the default timeline of the current document. This timeline is a special instance of DocumentTimeline.

[Value("timeline")]
public DocumentTimeline Timeline { get; }

Property Value

DocumentTimeline

A DocumentTimeline object.

Remarks

This timeline is unique to each document and persists for the lifetime of the document including calls to Open(string, string).

This timeline expresses the time in milliseconds since TimeOrigin.
Prior to the time origin, the timeline is inactive, and its CurrentTime is null.

NOTE

A document timeline that is associated with a non-active document (a Document not associated with a Window, {{htmlelement("iframe")}}, or {{htmlelement("frame")}}) is also considered to be inactive.

-Web Animations API
-AnimationTimeline
-CurrentTime
-DocumentTimeline

See also on MDN

Title

The document.title property gets or sets the current title of the document.
When present, it defaults to the value of the <title>.

[Value("title")]
public string Title { get; set; }

Property Value

string

A string containing the document's title. If the title was overridden by setting document.title, it contains that value. Otherwise, it contains the title specified in the <title> element.newTitle is the new title of the document. The assignment
affects the return value of document.title, the title displayed for the
document (e.g., in the titlebar of the window or tab), and it also affects the DOM of the
document (e.g., the content of the <title> element in an HTML
document).

Remarks

URL

The URL read-only property of the Document
interface returns the document location as a string.

[Value("URL")]
public string URL { get; }

Property Value

string

A string containing the URL of the document.

Remarks

-The DocumentURI property which returns the same value.

See also on MDN

VisibilityState

The Document.visibilityState
read-only property returns the visibility of the document. It can be used to check whether the document is in the background or in a minimized window, or is otherwise not visible to the user.

[Value("visibilityState")]
public DocumentVisibilityState VisibilityState { get; }

Property Value

DocumentVisibilityState

A string with one of the following values:

Remarks

When the value of this property changes, the Documentvisibilitychange event is sent to the Document.

The Hidden property provides an alternative way to determine whether the page is hidden.

-Hidden
-Page Visibility API

See also on MDN

VlinkColor

IMPORTANT
Deprecated
The Document.vlinkColor property gets/sets the color of
links that the user has visited in the document.
[Value("vlinkColor")]
public string VlinkColor { get; set; }

Property Value

string

A string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").When set to the null value, that null value is converted to the empty string (""), so document.vlinkColor = null is equivalent to document.vlinkColor = "".

Remarks

WasDiscarded

[Value("wasDiscarded")]
public bool WasDiscarded { get; }

Property Value

bool

Methods

AdoptNode(Node)

Document.adoptNode() transfers a node/dom from another {{domxref("Document", "document", "", "1")}} into the method's document.
The adopted node and its subtree are removed from their original document (if any), and their OwnerDocument is changed to the current document.
The node can then be inserted into the current document.

[Value("adoptNode")]
public Node AdoptNode(Node node)

Parameters

node Node

Returns

Node

The copied importedNode in the scope of the importing document.After calling this method, importedNode and
externalNode are the same object.

NOTE
importedNode's
ParentNode is null, since it has not yet been
inserted into the document tree!

Remarks

CaptureEvents()

[Value("captureEvents")]
public GlobalObject.Undefined CaptureEvents()

Returns

GlobalObject.Undefined

CaretPositionFromPoint(Number, Number, CaretPositionFromPointOptions)

The caretPositionFromPoint() method of the Document interface returns a 'CaretPosition' object, containing the DOM node, along with the caret and caret's character offset within that node.

[Value("caretPositionFromPoint")]
public CaretPosition? CaretPositionFromPoint(Number x, Number y, CaretPositionFromPointOptions options = null)

Parameters

x Number
y Number
options CaretPositionFromPointOptions

Returns

CaretPosition

A 'CaretPosition' object or null.The returned value is null if there is no viewport associated with the document, if the x or y are negative or outside of the viewport region, or if the coordinates indicate a point where no text insertion point indicator could be inserted.

Remarks

-'CaretPosition'

See also on MDN

Clear()

IMPORTANT
Deprecated
The Document.clear() method does nothing, but doesn't raise any error.
[Value("clear")]
public GlobalObject.Undefined Clear()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Close()

The Document.close() method finishes writing to a
document, opened with Open(string, string).

[Value("close")]
public GlobalObject.Undefined Close()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

CreateAttribute(string)

The Document.createAttribute() method creates a new
attribute node, and returns it. The object created is a node implementing the
Attr interface. The DOM does not enforce what sort of attributes can be
added to a particular element in this manner.

[Value("createAttribute")]
public Attr CreateAttribute(string localName)

Parameters

localName string

Returns

Attr

A Attr node.

Remarks

CreateAttributeNS(string?, string)

The Document.createAttributeNS() method creates a new attribute node
with the specified namespace URI and qualified name, and returns it.
The object created is a node implementing the
Attr interface. The DOM does not enforce what sort of attributes can be
added to a particular element in this manner.

[Value("createAttributeNS")]
public Attr CreateAttributeNS(string? namespace_, string qualifiedName)

Parameters

namespace_ string
qualifiedName string

Returns

Attr

The new Attr node.

Remarks

CreateCDATASection(string)

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

[Value("createCDATASection")]
public CDATASection CreateCDATASection(string data)

Parameters

data string

Returns

CDATASection

A CDATA Section node.

Remarks

CreateComment(string)

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

[Value("createComment")]
public Comment CreateComment(string data)

Parameters

data string

Returns

Comment

A new Comment object.

Remarks

CreateDocumentFragment()

Creates a new empty DocumentFragment into which
DOM nodes can be added to build an offscreen DOM tree.

[Value("createDocumentFragment")]
public DocumentFragment CreateDocumentFragment()

Returns

DocumentFragment

A newly created, empty, DocumentFragment object, which is ready to have
nodes inserted into it.

Remarks

CreateElement(string, Union34)

In an HTML document, the document.createElement() method creates the HTML element specified by localName, or an HTMLUnknownElement if localName isn't recognized.

[Value("createElement")]
public Element CreateElement(string localName, Union34 options = default)

Parameters

localName string
options Union34

Returns

Element

The new Element.

NOTE
A new {{domxref("HTMLElement", "HTMLElement", "", "1")}} is returned if the document is an {{domxref("HTMLDocument", "HTMLDocument", , "1")}}, which is the most common case. Otherwise a new {{domxref("Element","Element",,"1")}} is returned.

Remarks

CreateElementNS(string?, string, Union35)

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

[Value("createElementNS")]
public Element CreateElementNS(string? namespace_, string qualifiedName, Union35 options = default)

Parameters

namespace_ string
qualifiedName string
options Union35

Returns

Element

The new Element.

Remarks

To create an element without specifying a namespace URI, use the
CreateElement(string, Union34) method.

-CreateElement(string, Union34)
-CreateTextNode(string)
-NamespaceURI

See also on MDN

CreateEvent(string)

IMPORTANT
Deprecated
WARNING
Many methods used with createEvent, such as initCustomEvent, are deprecated.
Use event constructors instead.
[Value("createEvent")]
public Event CreateEvent(string interface_)

Parameters

interface_ string

Returns

Event

An Event object.

Remarks

Creates an event of the type specified. The
returned object should be first initialized and can then be passed to
DispatchEvent(Event).

-Creating and dispatching events

See also on MDN

CreateNodeIterator(Node, ulong, NodeFilter?)

The Document.createNodeIterator() method returns a new NodeIterator object.

[Value("createNodeIterator")]
public NodeIterator CreateNodeIterator(Node root, ulong whatToShow = 0, NodeFilter? filter = null)

Parameters

root Node
whatToShow ulong
filter NodeFilter

Returns

NodeIterator

A new NodeIterator object.

Remarks

CreateProcessingInstruction(string, string)

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

[Value("createProcessingInstruction")]
public ProcessingInstruction CreateProcessingInstruction(string target, string data)

Parameters

target string
data string

Returns

ProcessingInstruction

None (GlobalObject.Undefined).

Remarks

The new node usually will be inserted into an XML document in order to accomplish anything with it, such as with InsertBefore(Node, Node?).

See also on MDN

CreateRange()

The Document.createRange() method returns a new
Range object.

[Value("createRange")]
public Range CreateRange()

Returns

Range

The created Range object.

Remarks

CreateTextNode(string)

Creates a new Text node. This method can be used to escape HTML
characters.

[Value("createTextNode")]
public Text CreateTextNode(string data)

Parameters

data string

Returns

Text

A Text node.

Remarks

CreateTreeWalker(Node, ulong, NodeFilter?)

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

[Value("createTreeWalker")]
public TreeWalker CreateTreeWalker(Node root, ulong whatToShow = 0, NodeFilter? filter = null)

Parameters

root Node
whatToShow ulong
filter NodeFilter

Returns

TreeWalker

A new TreeWalker object.

Remarks

-TreeWalker: Related interface

See also on MDN

ElementFromPoint(Number, Number)

The elementFromPoint()
method, available on the Document object, returns the topmost Element at the specified coordinates
(relative to the viewport).

[Value("elementFromPoint")]
public Element? ElementFromPoint(Number x, Number y)

Parameters

x Number
y Number

Returns

Element

The topmost Element object located at the specified coordinates.

Remarks

If the element at the specified point belongs to another document (for example, the
document of an iframe), that document's parent element is returned
(the <iframe> itself). If the element at the given point is anonymous
or XBL generated content, such as a textbox's scroll bars, then the first non-anonymous
ancestor element (for example, the textbox) is returned.

Elements with pointer-events set to none will be ignored,
and the element below it will be returned.

If the method is run on another document (like an <iframe>'s
subdocument), the coordinates are relative to the document where the method is being
called.

If the specified point is outside the visible bounds of the document or either
coordinate is negative, the result is null.

If you need to find the specific position inside the element, use
CaretPositionFromPoint(Number, Number, CaretPositionFromPointOptions).

-ElementsFromPoint(Number, Number)

See also on MDN

ElementsFromPoint(Number, Number)

The elementsFromPoint() method
of the Document interface returns an array of all elements
at the specified coordinates (relative to the viewport).
The elements are ordered from the topmost to the bottommost box of the viewport.

[Value("elementsFromPoint")]
public List<Element> ElementsFromPoint(Number x, Number y)

Parameters

x Number
y Number

Returns

List<Element>

An array of 'Element' objects, ordered from the topmost to the bottommost box of the viewport.

Remarks

ExecCommand(string, bool, string)

IMPORTANT
Deprecated
NOTE
Although the execCommand() method is deprecated, there are still some valid use cases that do not yet have viable alternatives. For example, unlike direct DOM manipulation, modifications performed by execCommand() preserve the undo buffer (edit history). For these use cases, you can still use this method, but test to ensure cross-browser compatibility, such as by using QueryCommandSupported(string).
[Value("execCommand")]
public bool ExecCommand(string commandId, bool showUI = false, string value = null)

Parameters

commandId string
showUI bool
value string

Returns

bool

A boolean value that is false if the command is unsupported or disabled.

NOTE
document.execCommand() only returns
true if it is invoked as part of a user interaction. You can&apos;t use it to
verify browser support before calling a command.

Remarks

The execCommand method implements multiple different commands. Some of them provide access to the clipboard, while others are for editing form inputs, contenteditable elements or entire documents (when switched to design mode).

To access the clipboard, the newer Clipboard API is recommended over execCommand().

Most commands affect the document&apos;s selection. For example, some commands (bold, italics, etc.) format the currently selected text, while others delete the selection, insert new elements (replacing the selection) or affect an entire line (indenting). Only the currently active editable element can be modified, but some commands (e.g., copy) can work without an editable element.

NOTE

Modifications performed by execCommand() may or may not trigger Elementbeforeinput and Elementinput events, depending on the browser and configuration. If triggered, the handlers for the events will run before execCommand() returns. Authors need to be careful about such recursive calls, especially if they call execCommand() in response to these events. From Firefox 82, nested execCommand() calls will always fail, see bug 1634262.

-Clipboard API
-MDN example: execCommands supported in your browser
-HTMLElement.ContentEditable
-DesignMode
-QueryCommandEnabled(string)
-QueryCommandState(string)
-QueryCommandSupported(string)

See also on MDN

ExitFullscreen()

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

[Value("exitFullscreen")]
public Task<GlobalObject.Undefined> ExitFullscreen()

Returns

Task<GlobalObject.Undefined>

A Promise which is resolved once the {{Glossary("user agent")}} has
finished exiting fullscreen mode. If an error occurs while attempting to exit
fullscreen mode, the catch() handler for the promise is called.

Remarks

ExitPictureInPicture()

The exitPictureInPicture() method of the Document interface
requests that a video contained
in this document, which is currently floating, be taken out of picture-in-picture
mode, restoring the previous state of the screen. This usually reverses the
effects of a previous call to RequestPictureInPicture().

[Value("exitPictureInPicture")]
public Task<GlobalObject.Undefined> ExitPictureInPicture()

Returns

Task<GlobalObject.Undefined>

A Promise, which is resolved once the {{Glossary("user agent")}} has
finished exiting picture-in-picture mode. If an error occurs while attempting to exit
fullscreen mode, the catch() handler for the promise is called.

Remarks

ExitPointerLock()

The exitPointerLock() method of the Document interface asynchronously releases a pointer lock previously requested through RequestPointerLock(PointerLockOptions).

[Value("exitPointerLock")]
public GlobalObject.Undefined ExitPointerLock()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

NOTE

While the exitPointerLock() method is called on the document, the requestPointerLock() method is called on an element.

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

-Document.PointerLockElement
-RequestPointerLock(PointerLockOptions)
-Pointer Lock

See also on MDN

GetElementsByClassName(string)

The getElementsByClassName method of
Document interface returns an array-like object
of all child elements which have all of the given class name(s).

[Value("getElementsByClassName")]
public HTMLCollection GetElementsByClassName(string classNames)

Parameters

classNames string

Returns

HTMLCollection

A live HTMLCollection of found elements.

Remarks

When called on
the Document object, the complete document is searched, including the
root node. You may also call GetElementsByClassName(string) on any element; it will return only elements which are descendants of the specified root element with the given class name(s).

WARNING

This is a live HTMLCollection. Changes in the DOM will
reflect in the array as the changes occur. If an element selected by this array no
longer qualifies for the selector, it will automatically be removed. Be aware of this
for iteration purposes.

See also on MDN

GetElementsByName(string)

The getElementsByName() method
of the Document object returns a NodeList Collection of
elements with a given name attribute in the document.

[Value("getElementsByName")]
public NodeList GetElementsByName(string elementName)

Parameters

elementName string

Returns

NodeList

A live NodeList collection, meaning it automatically updates as new elements with the same name are added to, or removed from, the document.

Remarks

-Document.GetElementById to return a reference to an element by its
unique id
-GetElementsByTagName(string) to return references to elements with
the same tag name
-Document.QuerySelector to return references to elements via CSS
selectors like &apos;div.myclass&apos;

See also on MDN

GetElementsByTagName(string)

The getElementsByTagName method of
Document interface returns an
HTMLCollection of elements with the given tag name.

[Value("getElementsByTagName")]
public HTMLCollection GetElementsByTagName(string qualifiedName)

Parameters

qualifiedName string

Returns

HTMLCollection

A live HTMLCollection of found elements in the order they appear in the tree.

Remarks

The complete
document is searched, including the root node. The returned HTMLCollection
is live, meaning that it updates itself automatically to stay in sync with the DOM tree
without having to call document.getElementsByTagName() again.

-GetElementsByTagName(string)
-Document.GetElementById to return a reference to an element by its
id
-GetElementsByName(string) to return a reference to an element by
its name
-Document.QuerySelector for powerful selectors via queries like
&apos;div.myclass&apos;

See also on MDN

GetElementsByTagNameNS(string?, string)

Returns a list of elements with the given tag name belonging to the given namespace.
The complete document is searched, including the root node.

[Value("getElementsByTagNameNS")]
public HTMLCollection GetElementsByTagNameNS(string? namespace_, string localName)

Parameters

namespace_ string
localName string

Returns

HTMLCollection

A live HTMLCollection of found elements in the order they appear in the tree.

Remarks

GetSelection()

The getSelection() method of the Document interface returns the Selection object associated with this document, representing the range of text selected by the user, or the current position of the caret.

[Value("getSelection")]
public Selection? GetSelection()

Returns

Selection

A Selection object, or null if the document has no browsing context (for example, it is the document of an iframe that is not attached to a document).

Remarks

HasFocus()

The hasFocus() method of the Document interface returns a boolean value indicating whether the document or any element inside the document has focus.
This method can be used to determine whether the active element in a document has focus.

[Value("hasFocus")]
public bool HasFocus()

Returns

bool

false if the active element in the document has no focus;
true if the active element in the document has focus.

Remarks

NOTE

When viewing a document, an element with focus is always the active element in the document, but an active element does not necessarily have focus.
For example, an active element within a popup window that is not the foreground doesn&apos;t have focus.

-Document.ActiveElement
-Using the Page Visibility API

See also on MDN

HasPrivateToken(string)

[Value("hasPrivateToken")]
public Task<bool> HasPrivateToken(string issuer)

Parameters

issuer string

Returns

Task<bool>

HasRedemptionRecord(string)

[Value("hasRedemptionRecord")]
public Task<bool> HasRedemptionRecord(string issuer)

Parameters

issuer string

Returns

Task<bool>

HasStorageAccess()

The hasStorageAccess() method of the Document interface returns a {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to third-party, unpartitioned cookies.

[Value("hasStorageAccess")]
public Task<bool> HasStorageAccess()

Returns

Task<bool>

A Promise that resolves with a boolean value indicating whether the document has access to third-party cookies — true if it does, and false if not.The result returned by this method can be inaccurate in a couple of circumstances:

NOTE
If the promise gets resolved and a user gesture event was being processed when the function was originally called, the resolve handler will run as if a user gesture was being processed, so it will be able to call APIs that require user activation.

Remarks

HasUnpartitionedCookieAccess()

The hasUnpartitionedCookieAccess() method of the Document interface returns a {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to third-party, unpartitioned cookies.

[Value("hasUnpartitionedCookieAccess")]
public Task<bool> HasUnpartitionedCookieAccess()

Returns

Task<bool>

A Promise that resolves with a boolean value indicating whether the document has access to third-party cookies — true if it does, and false if not.See HasStorageAccess() for more details.

Remarks

ImportNode(Node, bool)

The Document object's importNode() method creates a copy of a
Node or DocumentFragment from another document, to be
inserted into the current document later.

[Value("importNode")]
public Node ImportNode(Node node, bool subtree = false)

Parameters

node Node
subtree bool

Returns

Node

The copied importedNode in the scope of the importing document.

NOTE
importedNode's ParentNode is null, since it has not yet been inserted into the document tree!

Remarks

The imported node is not yet included in the document tree. To include it, you need to
call an insertion method such as AppendChild(Node) or
InsertBefore(Node, Node?) with a node that is
currently in the document tree.

Unlike AdoptNode(Node), the original node is not removed from its
original document. The imported node is a clone of the original.

-AdoptNode(Node), which behaves very similar to this method
-AppendChild(Node)
-InsertBefore(Node, Node?)

See also on MDN

MeasureElement(Element)

[Value("measureElement")]
public FontMetrics MeasureElement(Element element)

Parameters

element Element

Returns

FontMetrics

MeasureText(string, StylePropertyMapReadOnly)

[Value("measureText")]
public FontMetrics MeasureText(string text, StylePropertyMapReadOnly styleMap)

Parameters

text string
styleMap StylePropertyMapReadOnly

Returns

FontMetrics

Open(string, string)

The Document.open() method opens a document for
{{domxref(&quot;Document.write&quot;, &quot;writing&quot;, &quot;&quot;, &quot;1&quot;)}}.

[Value("open")]
public Document Open(string unused1 = null, string unused2 = null)

Parameters

unused1 string
unused2 string

Returns

Document

A Document object instance.

Remarks

This does come with some side effects. For example:

-Document
-Open(string, string, string)

See also on MDN

Open(string, string, string)

The Document.open() method opens a document for
{{domxref(&quot;Document.write&quot;, &quot;writing&quot;, &quot;&quot;, &quot;1&quot;)}}.

[Value("open")]
public Window? Open(string url, string name, string features)

Parameters

url string
name string
features string

Returns

Window

A Document object instance.

Remarks

This does come with some side effects. For example:

-Document
-Open(string, string, string)

See also on MDN

ParseHTMLUnsafe(Union57)

WARNING
This method parses its input as HTML, writing the result into the DOM.
APIs like this are known as injection sinks, and are potentially a vector for cross-site-scripting (XSS) attacks, if the input originally came from an attacker.
[Value("parseHTMLUnsafe")]
public static Document ParseHTMLUnsafe(Union57 html)

Parameters

html Union57

Returns

Document

A Document.

Remarks

You can mitigate this risk by always passing TrustedHTML objects instead of strings and enforcing trusted types.
See Security considerations for more information.

NOTE

DocumentparseHTML should almost always be used instead of this method — on browsers where it is supported — as it always removes XSS-unsafe HTML entities.

The parseHTMLUnsafe() static method of the Document object is used to parse HTML input, optionally filtering unwanted HTML elements and attributes, in order to create a new Document instance.

-Document.ParseHTML
-Element.SetHTML and SetHTMLUnsafe(Union85)
-ShadowRoot.SetHTML and SetHTMLUnsafe(Union89)
-ParseFromString(Union91, DOMParserSupportedType) for parsing HTML or XML into a DOM tree
-HTML Sanitizer API

See also on MDN

QueryCommandEnabled(string)

IMPORTANT
Deprecated
NOTE
Although the DocumentexecCommand method is deprecated, if you do decide to use it for reasons given on that page, you should consider checking the command's availability using queryCommandEnabled() to ensure compatibility.
[Value("queryCommandEnabled")]
public bool QueryCommandEnabled(string commandId)

Parameters

commandId string

Returns

bool

Returns a boolean value which is true if the command is enabled
and false if the command isn&apos;t.

Remarks

The Document.queryCommandEnabled() method reports whether
or not the specified editor command is enabled by the browser.

-ExecCommand(string, bool, string)
-QueryCommandSupported(string)

See also on MDN

QueryCommandIndeterm(string)

[Value("queryCommandIndeterm")]
public bool QueryCommandIndeterm(string commandId)

Parameters

commandId string

Returns

bool

QueryCommandState(string)

IMPORTANT
Deprecated
NOTE
Although the DocumentexecCommand method is deprecated, there are still some valid use cases that do not yet have viable alternatives, as mentioned in the execCommand() article. In these cases, you may find this method useful to implement a complete user experience, but test to ensure cross-browser compatibility.
[Value("queryCommandState")]
public bool QueryCommandState(string commandId)

Parameters

commandId string

Returns

bool

queryCommandState() can return a boolean value or null if the state is unknown.

Remarks

The queryCommandState() method will tell you if the current selection has a certain ExecCommand(string, bool, string) command applied.

-HTMLElement.ContentEditable
-DesignMode
-ExecCommand(string, bool, string)
-Browser bugs related to queryCommandState(): Scribe&apos;s &quot;Browser Inconsistencies&quot; documentation

See also on MDN

QueryCommandSupported(string)

IMPORTANT
Deprecated
NOTE
Although the DocumentexecCommand method is deprecated, if you do decide to use it for reasons given on that page, you should consider checking the command's availability using queryCommandSupported() to ensure compatibility.
[Value("queryCommandSupported")]
public bool QueryCommandSupported(string commandId)

Parameters

commandId string

Returns

bool

Returns a boolean value which is true if the command is supported
and false if the command isn&apos;t.

Remarks

The Document.queryCommandSupported() method reports
whether or not the specified editor command is supported by the browser.

-ExecCommand(string, bool, string)
-QueryCommandEnabled(string)

See also on MDN

QueryCommandValue(string)

[Value("queryCommandValue")]
public string QueryCommandValue(string commandId)

Parameters

commandId string

Returns

string

ReleaseEvents()

[Value("releaseEvents")]
public GlobalObject.Undefined ReleaseEvents()

Returns

GlobalObject.Undefined

RequestStorageAccess()

The requestStorageAccess() method of the Document interface allows content loaded in a third-party context (i.e., embedded in an {{htmlelement("iframe")}}) to request access to third-party cookies and unpartitioned state. This is relevant to user agents that, by default, block access to third-party, unpartitioned cookies to improve privacy (e.g., to prevent tracking), and is part of the Storage Access API.

[Value("requestStorageAccess")]
public Task<GlobalObject.Undefined> RequestStorageAccess()

Returns

Task<GlobalObject.Undefined>

A Promise that fulfills with undefined if the access to third-party cookies was granted and no types parameter was provided, fulfills with StorageAccessHandle if the access to unpartitioned state requested by the types parameter was provided, and rejects if access was denied.requestStorageAccess() requests are automatically denied unless the embedded content is currently processing a user gesture such as a tap or click (transient activation), or unless permission was already granted previously. If permission was not previously granted, they need to be run inside a user gesture-based event handler. The user gesture behavior depends on the state of the promise:

Remarks

To check whether permission to access third-party cookies has already been granted, you can call Query(Object), specifying the feature name &quot;storage-access&quot;.

NOTE

Usage of this feature may be blocked by a Permissions-Policy/storage-access Permissions Policy set on your server. In addition, the document must pass additional browser-specific checks such as allowlists, blocklists, on-device classification, user settings, anti-clickjacking heuristics, or prompting the user for explicit permission.

-HasStorageAccess(), HasUnpartitionedCookieAccess(), RequestStorageAccessFor(string)
-Using the Storage Access API
-Introducing Storage Access API (WebKit blog)

See also on MDN

RequestStorageAccessFor(string)

NOTE
Experimental
The requestStorageAccessFor() method of the Document interface allows top-level sites to request third-party cookie access on behalf of embedded content originating from another site in the same related website set. It returns a Promise that resolves if the access was granted, and rejects if access was denied.
[Value("requestStorageAccessFor")]
public Task<GlobalObject.Undefined> RequestStorageAccessFor(string requestedOrigin)

Parameters

requestedOrigin string

Returns

Task<GlobalObject.Undefined>

A Promise that fulfills with undefined if the access to third-party cookies was granted and rejects if access was denied.requestStorageAccessFor() requests are automatically denied unless the top-level content is currently processing a user gesture such as a tap or click (transient activation), or unless permission was already granted previously. If permission was not previously granted, they must run inside a user gesture-based event handler. The user gesture behavior depends on the state of the promise:

Remarks

StartViewTransition(Union20)

The startViewTransition() method of the Document interface starts a new same-document (SPA) view transition and returns a ViewTransition object to represent it.

[Value("startViewTransition")]
public ViewTransition StartViewTransition(Union20 callbackOptions = default)

Parameters

callbackOptions Union20

Returns

ViewTransition

A ViewTransition object instance.

Remarks

When startViewTransition() is invoked, a sequence of steps is followed as explained in The view transition process.

-:active-view-transition pseudo-class
-:active-view-transition-type pseudo-class
-Smooth transitions with the View Transition API

See also on MDN

Write(params Union58[])

IMPORTANT
Deprecated
WARNING
Use of the document.write() method is strongly discouraged.
Avoid using it, and where possible replace it in existing code.
[Value("write")]
public GlobalObject.Undefined Write(params Union58[] text)

Parameters

text Union58[]

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

As the HTML spec itself warns:

This method has very idiosyncratic behavior.
In some cases, this method can affect the state of the HTML parser while the parser is running, resulting in a DOM that does not correspond to the source of the document (e.g., if the string written is the string &quot;&lt;plaintext&gt;&quot; or &quot;&lt;!--&quot;).
In other cases, the call can clear the current page first, as if Open(string, string) had been called.
In yet more cases, the method is simply ignored, or throws an exception. Users agents are explicitly allowed to avoid executing script elements inserted via this method.
And to make matters even worse, the exact behavior of this method can in some cases be dependent on network latency, which can lead to failures that are very hard to debug.
For all these reasons, use of this method is strongly discouraged.

WARNING

This method parses its input as HTML, writing the result into the DOM.
APIs like this are known as injection sinks, and are potentially a vector for cross-site-scripting (XSS) attacks, if the input originally came from an attacker.

You can mitigate this risk by always passing TrustedHTML objects instead of strings and enforcing trusted types.
See Security considerations for more information.

The write() method of the Document interface writes text in one or more TrustedHTML or string parameters to a document stream opened by Open(string, string).

-Writeln(params Union59[])
-InnerHTML
-CreateElement(string, Union34)
-Trusted Types API
-Cross-site scripting (XSS)

See also on MDN

Writeln(params Union59[])

IMPORTANT
Deprecated
WARNING
This method parses its input as HTML, writing the result into the DOM.
APIs like this are known as injection sinks, and are potentially a vector for cross-site-scripting (XSS) attacks, if the input originally came from an attacker.
[Value("writeln")]
public GlobalObject.Undefined Writeln(params Union59[] text)

Parameters

text Union59[]

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

You can mitigate this risk by always passing TrustedHTML objects instead of strings and enforcing trusted types.
See Security considerations for more information.

The writeln() method of the Document interface writes text in one or more TrustedHTML or string parameters to a document stream opened by Open(string, string), followed by a newline character.

See also on MDN