Name

write( ), writeln( ) — NN 2 IE 3 DOM n/a

Synopsis

write(”string“)

writeln(”string“)

When invoked as the page loads, these methods can dynamically add content to the page. When invoked after the page has loaded, a single method invocation clears the current document, opens a new output stream, and writes the content to the window or frame. A document.close( ) method is required afterward. Because the first document.write( ) or document.writeln( ) method destroys the current document, do not use two or more writing statements to create a new document. Instead load the content into one variable and pass that variable as the parameter to a single document.write( ) or document.writeln( ) method.

The difference between the two methods is that document.writeln( ) adds a carriage return to the source code it writes to the document. This is not reflected in the rendered content, but can make reading the dynamic source code easier in browser versions that support dynamic content source viewing (Navigator does so as a wysiwyg: URL in the source view window).

Returned Value

None.

Parameters

string

Any string value, including HTML tags. To write <SCRIPT> tags, use entity characters for the brackets: &lt;SCRIPT&gt;.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.