HTML DOM open() Method

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP







<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]
-->



HTML DOM open() Method


❮ 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 open() method opens an output stream to collect the output from any
document.write() or
document.writeln() methods.


Once all the writes are performed, the
document.close() method causes any output written to the output stream to be
displayed.


Note: If a document already exists in the target, it will be cleared.


Note: Do not confuse this method with the
window.open() method, which opens a new browser
window.



Browser Support














Method
open() Yes Yes Yes Yes Yes

Syntax



document.open(MIMEtype, replace)

Parameter Values








Parameter Description
MIMEtype Optional. The type of document you are writing to. Default value is "text/html"
replace Optional. If set, the history entry for the new document inherits the history entry from the document which opened this document




<!--
mid_content, all: [300,250][336,280][728,90][970,250][970,90][320,50][468,60]
-->




Technical Details




Return Value: No return value

More Examples



Example


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



document.open("text/html", "replace");

document.write("<html><body><p>Hello World!</p></body></html>");
document.close();

Try it Yourself »



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 »



❮ Document Object

Popular posts from this blog

Malaysia to Papua New Guinea by motorcycle?

List of Bhojpuri films

PHP code is not being executed, instead code shows on the page