--- title: Document.writeln() slug: Web/API/Document/writeln tags: - API - DOM - Method - Reference - メソッド translation_of: Web/API/Document/writeln --- <p>{{ ApiRef("DOM") }}</p> <p>テキストの文字列とその直後に続く改行文字を文書に書き込みます。</p> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="eval">document.writeln(<em>line</em>); </pre> <h3 id="Parameters" name="Parameters">引数</h3> <ul> <li><code>line</code> はテキストの行を含む文字列です。</li> </ul> <h2 id="Example" name="Example">Example</h2> <pre>document.writeln("<p>パスワードを入力してください:</p>"); </pre> <h2 id="Notes" name="Notes">メモ</h2> <p><strong>document.writeln</strong> は {{domxref("document.write")}} と同じですが、改行文字を追加します。</p> <div class="note"><strong>メモ:</strong> <strong>document.writeln</strong> は (<strong>document.write</strong> と同様に) XHTML 文書では動作しません (エラーコンソールに "Operation is not supported" [<code>NS_ERROR_DOM_NOT_SUPPORTED_ERR</code>] エラーが表示されます)。これは、 .xhtml の拡張子を持つローカルファイルを開いたり、何らかの文書が <code>application/xhtml+xml</code> の MIME タイプで提供されたときに発生します。詳細は <a href="http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite">W3C XHTML FAQ</a> で確認することができます。</div> <h2 id="Specifications" name="Specifications">仕様書</h2> <table class="standard-table"> <thead> <tr> <th scope="col">仕様書</th> <th scope="col">状態</th> <th scope="col">備考</th> </tr> </thead> <tbody> <tr> <td>{{SpecName("HTML WHATWG", "#dom-document-writeln", "document.writeln()")}}</td> <td>{{Spec2("HTML WHATWG")}}</td> <td> </td> </tr> <tr> <td>{{SpecName("DOM2 HTML", "html.html#ID-35318390", "document.writeln()")}}</td> <td>{{Spec2("DOM2 HTML")}}</td> <td> </td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> <p>{{Compat("api.Document.writeln")}}</p>