Document.open() (Method)

Open a document body ready for writing.

Availability:

DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
JavaScript syntax:-myDocument.open()
-myDocument.open(aMimeType)
-myDocument.open(aMimeType, aReplaceFlag)
Argument list:aMimeTypeA text string describing a valid mime types for the document
aReplaceFlagA string containing the word "replace"

This opens and prepares the document in readiness for a document.write() action.

Although the document.close() is required, the document.open() may be omitted. Some browsers may be permissive enough to allow the document.write() actions to work without a document.open() first but occasionally a browser may fail. It is good coding style to observe the discipline of opening a stream before writing to it.

The optional parameter describes the MIME type of the document to be opened. By default this will be "text/html". The "text/plain" MIME type is useful too. You can, in theory, open any kind of document but most binary formats are just not practical.

Refer to the MIME type topic for details of some available MIME type values.

The DOM level 1 specification suggests that this method may be deprecated in the future.

Warnings:

See also:Debugging - client side, Document object, Document.close(), Document.write(), Document.writeln(), MIME types, Window.open()