JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Document.clear() Method

Name

Document.clear() Method---clear a document

Availability

deprecated; do not use

Synopsis

document.clear()

Arguments

none

Returns

nothing

Description

document.clear() temporarily erases the specified document (i.e., it clears the window or frame that contains document). This method does not actually remove the contents of the document, and if the window is covered and then uncovered, for example, the document will be redrawn. This is unusual and generally undesirable behavior, and the use of the clear() method is not recommended.

Furthermore, Internet Explorer 3.0 defines this function in an compatible way. On that platform, the clear() method is simply a synonym for Document.open().

The clear() method will be removed from JavaScript in a future version of the language. When you want to use JavaScript to delete the current document and begin a new one, you should first call the close() method for the current document, then call the open() method to open a new document, and then use the write() and writeln() methods to write out the contents of the new document. When you are writing HTML text, you can omit the call to open()--a new text/html document will be automatically opened if you call write() or writeln() without first calling open().

See Also

"Document", "Document.close()", "Document.open()", "Document.write()"


Previous Home Next
Document.bgColor Book Index Document.close()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell