Document.close() (Method)

Close a document body after you have finished writing to it.

Availability:

DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
JavaScript syntax:-myDocument.close()

Calling the document.close() method will cause the output buffer to be flushed, stop the rotating loading icon and force the display of any HTML you have written. In some browsers this may happen automatically when the script exits and in others you will need to do it explicitly. It is good coding style to close a stream when you have finished writing to it. This is analogous to thefflush() call that C programmers make to force the buffered output to be sent through an I/O stream.

If you close a document stream and then proceed to write to it again, the document will be implicitly cleared and reopened. That is as if you had performed a document.clear() and then a document.open(). Any content that you had just written and then terminated with the document.close() will be discarded and a new document body started.

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

See also:Document object, Document.open(), Document.write(), Document.writeln()