Writing To The Default Document


Seeing How Text Flows

In your sample document after the line

Add

And resave and run the new program.

Notice how the text runs together.

Placing HTML Tags In Your JavaScript Output

When writing to the HTML document, you must always remember that it is processed as if it was normal html, all html tags will be honoured and processed.

Change the following lines in your program

To read

Rerun the program.

Remember Your Text Inherits Whatever Attributes The Previous Text Had, And Passes It's Along

Just after the body tag add the line.

Between the two document.write statements
Add The following

Before the </body> tag add the line

Rerun the program.

While viewing the document do a View Source and observe the results.

Writeln Method

A variation on the write method is the writeln method, which puts out an eoln after printing out the string characters. This is not useful in formatting the text as HTML ignores the eoln in the document. It's only useful if you are outputting text with the <PRE>tag.

Back