HTML DOM close() Method

Document Object Reference Document Object

Example

Open an output stream, add some text, then close the output stream:

document.open();
document.write("<h1>Hello World</h1>");
document.close();

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The close() method closes the output stream previously opened with the document.open() method, and displays the collected data in this process.


Browser Support

Method
close() Yes Yes Yes Yes Yes

Syntax

document.close()

Parameter Values

None

Technical Details

Return Value: No return value

Examples

More Examples

Example

Using window.open() together with document.open() to open an output stream in a new window, add some text, then close the output stream:

var w = window.open();
w.document.open();
w.document.write("<h1>Hello World!</h1>");
w.document.close();

Try it yourself »

Related Pages

HTML DOM reference: HTML DOM open() method

HTML DOM reference: HTML DOM write() method

HTML DOM reference: HTML DOM writeln() method

Browser BOM reference: Window open() method


Document Object Reference Document Object

SHARE THIS PAGE

COLOR PICKER

colorpicker