Return to Kroll Design home page

JavaScript Tutorials

 
« Return

writeln() method

document.writeln(string) will create/write whatever string you specify, whether string is a variable, or a literal.
In theory, writeln is supposed to do a carriage return at the end of the line, but when I tested it, it didn't work right. So if you want to ensure a line break, just use write instead of writeln, and in the write, include the <br /> or <p> tag.

Output:

Code:

<script type="text/javascript">
//<![CDATA[
document.write("This uses <strong>writeln</strong>:<br />"); document.writeln("line1"); document.writeln("line2"); document.writeln("line3"); document.write("<br /><br />This uses <strong>write</strong> and &lt;br /&gt;:<br />"); document.write("line1<br />"); document.write("line2<br />"); document.write("line3<br />"); //]]> </script>


 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM