Name
HTMLDocument.open( ): begin a new document, erasing the current one â DOM Level 0
Synopsis
void open( );
Description
This method erases the current HTML document and begins a new
one, which may be written to with the write( )
and writeln( )
methods. After calling open( )
to begin a new document and
write( )
to specify document
content, you must always remember to call close( )
to end the document and force its
content to be displayed.
This method should not be called by a script or event handler that is part of the document being overwritten, because the script or handler will itself be overwritten.
Example
var w = window.open(""); // Open a new window var d = w.document; // Get its HTMLDocument object d.open( ); // Open the document for writing d.write("<h1>Hello world</h1>"); // Output some HTML to the document d.close( ); // End the document and display it
See Also
HTMLDocument.close( )
,
HTMLDocument.write( )
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.