This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

close

Summary

Closes an output stream and forces the sent data to display.

Method of dom/Documentdom/Document

Syntax

 document.close();

Return Value

No return value

Examples

//open a new window/tab, open a new document in it,
//write to the document, and close the document (but not the window/tab)
function newWinDoc() {
    var win=window.open();
    win.document.open();
    win.document.write("<h1>Hello, world</h1>");
    win.document.close();
}

Notes

When a function fired by an event on any object calls the close method, the window.close method is implied. When an event on any object calls the ****close**** method, the document.close method is implied.

When document.write or document.writeln is used in an event handler, document.close should also be used.

Related specifications

DOM Level 2 HTML
Recommendation

See also

Related pages

Attributions