HTML DOM writeln()Method

Document 对象参考手册Document Object

Definition and Usage

The writeln() method has the same effect as the write() method, plus it can write a newline character after each expression.

Syntax

document.writeln(exp1,exp2,exp3,...)

Parameters Description
exp1,exp2,exp3,... Optional. The output to be written. They will be appended to the document in order.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the writeln() method


Examples

Examples

The difference between write() and writeln():

<html>
<body>

<p>Note that write() does NOT add a new line after each statement:</p>

<pre>
<script>
document.write("Hello World!");
document.write("Have a nice day!");
</script>
</pre>


<p>Note that writeln() add a new line after each statement:</p>

<pre>
<script>
document.writeln("Hello World!");
document.writeln("Have a nice day!");
</script>
</pre>

</body>
</html>

Try it yourself »


Document 对象参考手册Document Object Other Extensions