TOC PREV NEXT INDEX

domref



write


Writes a string of text to a document stream opened by document.open()

Syntax

document.write(text)
 

Parameters

text is a string containing the text to be written to the current document.

Example

document.open();
 
document.write("<h1>hello!</h1>");
 
document.close();
 

Notes

Writing to a document that has already loaded without calling document.open() will automatically perform a document.open() call. Once you have finished writing, it is recommended to call document.close(), to tell the browser to finish loading the page. The text you write is parsed into the document's structure model. In the example above, the H1 element becomes a node in the document.

If the document.write() call is embedded directly in the HTML code, then it will not call document.open(). For example:

<div>
 
  <script type="text/javascript">
 
    document.write("<h1>Main title</h1>")
 
  </script>
 
</div>
 

 

Specification

write
 


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX