méthode DOM HTML writeln ()
Définition et utilisation
méthode writeln () avec la méthode write () de la même action, plus écrire un saut de ligne après chaque expression.
grammaire
document.writeln(exp1,exp2,exp3,...)
参数 | 描述 |
---|---|
exp1,exp2,exp3,... | 可选.要写入的输出流。它们将按顺序被追加到文档中。 |
support du navigateur
Tous les principaux navigateurs supportent writeln méthode ()
Exemples
Exemples
Différences écrivent () et writeln () entre:
<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>
<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>
Essayez »
Document Object