Back to Content

Document: close() method

files/en-us/web/api/document/close/index.md

latest522 B
Original Source

{{APIRef("DOM")}}

The Document.close() method finishes writing to a document, opened with {{domxref("Document.open()")}}.

Syntax

js-nolint
close()

Parameters

None.

Return value

None ({{jsxref("undefined")}}).

Examples

js
// Open a document to write to it
document.open();

// Write the content of the document
document.write("<p>The one and only content.</p>");

// Close the document
document.close();

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}