X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET 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:

var doc=document.open("text/html","replace");
var txt="<html><body>Learning about the HTML DOM is fun!</body></html>";
doc.write(txt);
doc.close();

Try it yourself »


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

Internet Explorer Firefox Opera Google Chrome Safari

The close() method is supported in all major browsers.


Syntax

document.close()

Parameters

None.

Return Value

No return value.

Technical Details

DOM Version Core Level 2 Document Object


More Examples

Example 2

Open an output stream (in a new window; about:blank), add some text, then close the output stream:

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

Try it yourself »


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 BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook