Name
Document.open( ) — begin a new document
Availability
JavaScript 1.0
Synopsis
document
.open( )document
.open(mimetype
)
Arguments
-
mimetype
An optional string argument that specifies the type of data to be written to and displayed in
document
. The value of this argument should be one of the standard MIME types that the browser understands (“text/html”, “text/plain”, “image/gif”, “image/jpeg”, and “image/x-bitmap” for Netscape) or some other MIME type that can be handled by an installed plugin. If this argument is omitted, it is taken to be “text/html”. This argument is ignored by IE 3, which always assumes a document of type “text/html”. This argument is also not supported in the standard W3C DOM version of this method. See the HTMLDocument.open( ) entry in the DOM reference section.
Description
The document
.open( )
method opens a stream to document
so
subsequent document
.write( )
calls can append data to the document. The optional
mimetype
argument specifies the type of
data to be written and tells the browser how to interpret that data.
If any existing document is displayed when the open( )
method is called, it is automatically cleared by the call
to open( )
or by the first call to write( )
or writeln( )
. After opening a
document with open( )
and writing data to it with
write( )
, you should complete the document by
calling close( )
.
Usage
You usually call Document.open( )
with no argument to open an HTML document. Occasionally, a “text/plain” document is useful, for example, for ...
Get JavaScript: The Definitive Guide, Fourth 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.