DOM:document.open
From MDC
Contents |
[edit] Summary
The document.open() method opens a document for writing.
[edit] Syntax
document.open();
[edit] Example
// In this example, the document contents are
// overwritten as the document
// is reinitialized on open().
document.write("<html><p>remove me</p></html>");
document.open();
// document is empty.
[edit] Notes
If a document exists in the target, this method clears it (see the example above).
Also, an automatic document.open() call happens when document.write() is called after the page has loaded, but that's not defined in the W3C specification.
Do not confuse this method with window.open(). document.open allows you to overwrite the current document or append to it, while window.open provides a way to open a new window, leaving the current document intact. Since window is the global object, just calling open(...) does the same as window.open(...).
You can close the opened document using document.close().
Starting with Firefox 3, this method is subject to the same same-origin policy as other properties, and does not work if doing so would change the document's origin.