X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook