Latest web development tutorials

HTML DOM writeln () method

Document Object Reference Document Object

Definition and Usage

writeln () method with the write () method of the same action, plus write a line break after each expression.

grammar

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

参数 描述
exp1,exp2,exp3,... 可选.要写入的输出流。它们将按顺序被追加到文档中。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support writeln () method


Examples

Examples

Differences write () and writeln () between:

<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"


Document Object Reference Document Object