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.
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
Deprecatedduring 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 thenullvalue, thatnullvalue is converted to the empty string (""), sodocument.alinkColor = nullis equivalent todocument.alinkColor = "".
Remarks
All
IMPORTANT
Deprecatedall 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:
Anchors
IMPORTANT
Deprecatedanchors read-only property of theDocument interface returns a list of all of the anchors in the document.
[Value("anchors")]
public HTMLCollection Anchors { get; }
Property Value
Remarks
Applets
IMPORTANT
Deprecatedapplets 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, callingdocument.appletsalways
returns an empty collection.
BgColor
IMPORTANT
DeprecatedbgColor property gets or sets the background color of thecurrent 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 thenullvalue, thatnullvalue is converted to the empty string (""), sodocument.bgColor = nullis equivalent todocument.bgColor = "".
Remarks
Body
The Document.body property represents the
body or frameset node of the current document, ornull 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.
Charset
[Value("charset")]
public string Charset { get; }
Property Value
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
contentTypeis a read-only property.
Remarks
NOTE
This property is unaffected by meta
elements.
Cookie
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=valuepairs).
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
Thedocument.cookieproperty 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.
Remarks
-HTTP cookies
-DOM Storage
-URL.pathname
-DateToUTCString
-RFC 2965
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
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
Remarks
This property is read-only.
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
designModeis (or should be) set to on or off.
Valid values areonandoff.
Remarks
-HTMLElement.ContentEditable
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
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
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.
Domain
IMPORTANT
Deprecateddomain property of the Documentinterface 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
-Same-origin policy
-Hostname
-Host
-Window.Origin
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
Remarks
FgColor
IMPORTANT
DeprecatedfgColor gets/sets the foreground color, or text color, ofthe 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-indocument["login-form"]property in the future, your code may no longer be able to access the form element.
To avoid such conflicts, always usedocument.formsto access named forms.
-HTML forms
-{{HTMLElement("form")}} and the HTMLFormElement interface
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")}}
Fullscreen
IMPORTANT
Deprecatedfullscreen 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
trueif the document is currently displaying an element in fullscreen mode; otherwise, the value isfalse.
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
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
trueif the document and the
elements within can be placed into fullscreen mode by calling
RequestFullscreen(FullscreenOptions). If fullscreen mode isn't available, this
value isfalse.
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
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
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,
trueif the page is hidden, andfalseotherwise.
Remarks
The VisibilityState property provides an alternative way to determine whether the page is hidden.
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
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
DeprecatedDocument.linkColor property gets/sets the color oflinks 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 thenullvalue, thatnullvalue is converted to the empty string (""), sodocument.linkColor = nullis equivalent todocument.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.
Links
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
Remarks
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
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 ofdocument.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 isnull.
-The interface of the returned value, Location
-A similar information, but attached to the browsing context,
Location
NamedFlows
[Value("namedFlows")]
public NamedFlowMap NamedFlows { get; }
Property Value
Onfreeze
[Value("onfreeze")]
public EventHandlerNonNull Onfreeze { get; set; }
Property Value
Onfullscreenchange
[Value("onfullscreenchange")]
public EventHandlerNonNull Onfullscreenchange { get; set; }
Property Value
Onfullscreenerror
[Value("onfullscreenerror")]
public EventHandlerNonNull Onfullscreenerror { get; set; }
Property Value
Onpointerlockchange
[Value("onpointerlockchange")]
public EventHandlerNonNull Onpointerlockchange { get; set; }
Property Value
Onpointerlockerror
[Value("onpointerlockerror")]
public EventHandlerNonNull Onpointerlockerror { get; set; }
Property Value
Onprerenderingchange
[Value("onprerenderingchange")]
public EventHandlerNonNull Onprerenderingchange { get; set; }
Property Value
Onreadystatechange
[Value("onreadystatechange")]
public EventHandlerNonNull Onreadystatechange { get; set; }
Property Value
Onresume
[Value("onresume")]
public EventHandlerNonNull Onresume { get; set; }
Property Value
Onvisibilitychange
[Value("onvisibilitychange")]
public EventHandlerNonNull Onvisibilitychange { get; set; }
Property Value
PermissionsPolicy
[Value("permissionsPolicy")]
public PermissionsPolicy PermissionsPolicy { get; }
Property Value
PictureInPictureEnabled
The read-onlypictureInPictureEnabled 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
trueif 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 isfalse.
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
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
Remarks
NOTE
For a list of installed plugins, use Navigator.plugins
instead.
Prerendering
CAUTION
Non-standardprerendering 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
trueif the document is currently in the process of prerendering, andfalseif it is not.falsewill be returned for documents that have finished prerendering, and documents that were not prerendered.
Remarks
-Speculation Rules API
-Document.Prerenderingchange event
-ActivationStart property
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
readyStateof a document can be one of following:
Remarks
-Related events:-Documentreadystatechange
-DocumentDOMContentLoaded
-Windowload
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, theDocument.referrerwill 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'sWindow.locationby default.
For more information, see the Referrer-Policy: strict-origin-when-cross-origin documentation.
Remarks
RootElement
IMPORTANT
DeprecatedDocument.rootElement returns the Elementthat is the root element of the Document if it is an
svg element, otherwise
null. It is deprecated in favor ofDocumentElement, 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 therootElementwill be
an SVGSVGElement, identical to thedocumentElement.
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 HTMLbody 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.
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
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.newTitleis the new title of the document. The assignment
affects the return value ofdocument.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.
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.
VlinkColor
IMPORTANT
DeprecatedDocument.vlinkColor property gets/sets the color oflinks 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 thenullvalue, thatnullvalue is converted to the empty string (""), sodocument.vlinkColor = nullis equivalent todocument.vlinkColor = "".
Remarks
WasDiscarded
[Value("wasDiscarded")]
public bool WasDiscarded { get; }
Property Value
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
nodeNode
Returns
- Node
The copied
importedNodein the scope of the importing document.After calling this method,importedNodeandexternalNodeare the same object.NOTE
importedNode's
ParentNode isnull, since it has not yet been
inserted into the document tree!
Remarks
CaptureEvents()
[Value("captureEvents")]
public GlobalObject.Undefined CaptureEvents()
Returns
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
xNumberyNumberoptionsCaretPositionFromPointOptions
Returns
- CaretPosition
A 'CaretPosition' object or
null.The returned value isnullif there is no viewport associated with the document, if thexoryare 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'
Clear()
IMPORTANT
DeprecatedDocument.clear() method does nothing, but doesn't raise any error.
[Value("clear")]
public GlobalObject.Undefined Clear()
Returns
Remarks
Close()
The Document.close() method finishes writing to a
document, opened with Open(string, string).
[Value("close")]
public GlobalObject.Undefined Close()
Returns
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
localNamestring
Returns
Remarks
NOTE
The string given in parameter is converted to lowercase.
-CreateAttributeNS(string?, string)
-CreateElement(string, Union34)
-SetAttribute(string, string)
-SetAttributeNode(Attr)
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
Returns
Remarks
-CreateAttribute(string)
-CreateElementNS(string?, string, Union35)
-SetAttributeNS(string?, string, string)
-SetAttributeNode(Attr)
-SetAttributeNodeNS(Attr)
CreateCDATASection(string)
createCDATASection() creates a new CDATA section node,
and returns it.
[Value("createCDATASection")]
public CDATASection CreateCDATASection(string data)
Parameters
datastring
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
datastring
Returns
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
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
-RemoveChild(Node)
-ReplaceChild(Node, Node)
-AppendChild(Node)
-InsertBefore(Node, Node?)
-HasChildNodes()
-CreateElementNS(string?, string, Union35) — to explicitly specify the namespace URI for the element.
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
Returns
Remarks
To create an element without specifying a namespace URI, use the
CreateElement(string, Union34) method.
-CreateElement(string, Union34)
-CreateTextNode(string)
-NamespaceURI
CreateEvent(string)
IMPORTANT
DeprecatedWARNING
Many methods used withcreateEvent, such asinitCustomEvent, are deprecated.
Use event constructors instead.
[Value("createEvent")]
public Event CreateEvent(string interface_)
Parameters
interface_string
Returns
Remarks
Creates an event of the type specified. The
returned object should be first initialized and can then be passed to
DispatchEvent(Event).
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
rootNodewhatToShowulongfilterNodeFilter
Returns
- NodeIterator
A new
NodeIteratorobject.
Remarks
CreateProcessingInstruction(string, string)
createProcessingInstruction() generates a new processing instruction node and returns it.
[Value("createProcessingInstruction")]
public ProcessingInstruction CreateProcessingInstruction(string target, string data)
Parameters
Returns
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?).
CreateRange()
The Document.createRange() method returns a new
Range object.
[Value("createRange")]
public Range CreateRange()
Returns
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
datastring
Returns
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
rootNodewhatToShowulongfilterNodeFilter
Returns
- TreeWalker
A new TreeWalker object.
Remarks
-TreeWalker: Related interface
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
Returns
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)
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
Returns
- List<Element>
An array of 'Element' objects, ordered from the topmost to the bottommost box of the viewport.
Remarks
It operates in a similar way to the ElementFromPoint(Number, Number) method.
ExecCommand(string, bool, string)
IMPORTANT
DeprecatedNOTE
Although theexecCommand()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 byexecCommand()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
Returns
- bool
A boolean value that is
falseif the command is unsupported or disabled.NOTE
document.execCommand()only returnstrueif it is invoked as part of a user interaction. You can'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'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 beforeexecCommand()returns. Authors need to be careful about such recursive calls, especially if they callexecCommand()in response to these events. From Firefox 82, nestedexecCommand()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)
ExitFullscreen()
The Document methodexitFullscreen() 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, thecatch()handler for the promise is called.
Remarks
-Fullscreen API
-Guide to the Fullscreen API
-RequestFullscreen(FullscreenOptions)
-Document.FullscreenElement
-:fullscreen and {{cssxref("::backdrop")}}
-The iframe allowfullscreen
attribute
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, thecatch()handler for the promise is called.
Remarks
-RequestPictureInPicture()
-DisablePictureInPicture
-PictureInPictureEnabled
-Document.PictureInPictureElement
-:picture-in-picture
-Picture-in-Picture events
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
Remarks
NOTE
While the
exitPointerLock()method is called on the document, therequestPointerLock()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
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
classNamesstring
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.
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
elementNamestring
Returns
- NodeList
A live NodeList collection, meaning it automatically updates as new elements with the same
nameare 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 'div.myclass'
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
qualifiedNamestring
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 itsid
-GetElementsByName(string) to return a reference to an element by
its name
-Document.QuerySelector for powerful selectors via queries like'div.myclass'
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
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
nullif 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
falseif the active element in the document has no focus;trueif 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't have focus.
-Document.ActiveElement
-Using the Page Visibility API
HasPrivateToken(string)
[Value("hasPrivateToken")]
public Task<bool> HasPrivateToken(string issuer)
Parameters
issuerstring
Returns
HasRedemptionRecord(string)
[Value("hasRedemptionRecord")]
public Task<bool> HasRedemptionRecord(string issuer)
Parameters
issuerstring
Returns
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 —
trueif it does, andfalseif 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
This method is part of the Storage Access API.
NOTE
This method is another name for HasUnpartitionedCookieAccess(). There are no current plans to remove this method in favor of HasUnpartitionedCookieAccess().
-HasUnpartitionedCookieAccess(), RequestStorageAccess(), RequestStorageAccessFor(string)
-Using the Storage Access API
-Introducing Storage Access API (WebKit blog)
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 —
trueif it does, andfalseif not.See HasStorageAccess() for more details.
Remarks
This method is part of the Storage Access API.
This method is a new name for HasStorageAccess().
-HasStorageAccess(), RequestStorageAccess(), RequestStorageAccessFor(string)
-Using the Storage Access API
-Introducing Storage Access API (WebKit blog)
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
Returns
- Node
The copied
importedNodein the scope of the importing document.NOTE
importedNode's ParentNode isnull, 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?)
MeasureElement(Element)
[Value("measureElement")]
public FontMetrics MeasureElement(Element element)
Parameters
elementElement
Returns
MeasureText(string, StylePropertyMapReadOnly)
[Value("measureText")]
public FontMetrics MeasureText(string text, StylePropertyMapReadOnly styleMap)
Parameters
textstringstyleMapStylePropertyMapReadOnly
Returns
Open(string, string)
The Document.open() method opens a document for
{{domxref("Document.write", "writing", "", "1")}}.
[Value("open")]
public Document Open(string unused1 = null, string unused2 = null)
Parameters
Returns
- Document
A
Documentobject instance.
Remarks
This does come with some side effects. For example:
Open(string, string, string)
The Document.open() method opens a document for
{{domxref("Document.write", "writing", "", "1")}}.
[Value("open")]
public Window? Open(string url, string name, string features)
Parameters
Returns
- Window
A
Documentobject instance.
Remarks
This does come with some side effects. For example:
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
htmlUnion57
Returns
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
QueryCommandEnabled(string)
IMPORTANT
DeprecatedNOTE
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 usingqueryCommandEnabled()to ensure compatibility.
[Value("queryCommandEnabled")]
public bool QueryCommandEnabled(string commandId)
Parameters
commandIdstring
Returns
- bool
Returns a boolean value which is
trueif the command is enabled
andfalseif the command isn'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)
QueryCommandIndeterm(string)
[Value("queryCommandIndeterm")]
public bool QueryCommandIndeterm(string commandId)
Parameters
commandIdstring
Returns
QueryCommandState(string)
IMPORTANT
DeprecatedNOTE
Although the DocumentexecCommand method is deprecated, there are still some valid use cases that do not yet have viable alternatives, as mentioned in theexecCommand()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
commandIdstring
Returns
- bool
queryCommandState()can return a boolean value ornullif 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's "Browser Inconsistencies" documentation
QueryCommandSupported(string)
IMPORTANT
DeprecatedNOTE
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 usingqueryCommandSupported()to ensure compatibility.
[Value("queryCommandSupported")]
public bool QueryCommandSupported(string commandId)
Parameters
commandIdstring
Returns
- bool
Returns a boolean value which is
trueif the command is supported
andfalseif the command isn'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)
QueryCommandValue(string)
[Value("queryCommandValue")]
public string QueryCommandValue(string commandId)
Parameters
commandIdstring
Returns
ReleaseEvents()
[Value("releaseEvents")]
public GlobalObject.Undefined ReleaseEvents()
Returns
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
undefinedif the access to third-party cookies was granted and notypesparameter was provided, fulfills with StorageAccessHandle if the access to unpartitioned state requested by thetypesparameter 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 "storage-access".
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)
RequestStorageAccessFor(string)
NOTE
ExperimentalrequestStorageAccessFor() 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
requestedOriginstring
Returns
- Task<GlobalObject.Undefined>
A Promise that fulfills with
undefinedif 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
-HasStorageAccess(), HasUnpartitionedCookieAccess(), RequestStorageAccess()
-Using the Storage Access API
-Introducing Storage Access API (WebKit blog)
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
callbackOptionsUnion20
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
Write(params Union58[])
IMPORTANT
DeprecatedWARNING
Use of thedocument.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
textUnion58[]
Returns
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 "<plaintext>" or "<!--").
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 executingscriptelements 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
TrustedHTMLobjects 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)
Writeln(params Union59[])
IMPORTANT
DeprecatedWARNING
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
textUnion59[]
Returns
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.