HTML DOM writeln()メソッド

Document 对象参考手册Document オブジェクト

定義と用法

writeln() メソッドは write() メソッドと同様に動作しますが、各式の後に改行文字を書き込むことができます。

構文

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

引数 説明
exp1,exp2,exp3,... オプション。書き込む出力ストリーム。これらは順番にドキュメントに追加されます。


ブラウザ対応

Internet ExplorerFirefoxOperaGoogle ChromeSafari

すべての主要ブラウザが writeln() メソッドをサポートしています。


例

例

write() と 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>

試してみる »


Document 对象参考手册Document オブジェクト その他の拡張