document.writeln

  • Revision slug: Web/API/document.writeln
  • Revision title: document.writeln
  • Revision id: 477187
  • Created:
  • Creator: kscarfone
  • Is current revision? Yes
  • Comment Updated tags

Revision Content

{{ DomRef() }}

Summary

Writes a string of text followed by a newline character to a document.

Syntax

document.writeln(line); 

Parameters

  • line is string containing a line of text.

Example

document.writeln("<p>enter password:</p>"); 

Notes

document.writeln is the same as document.write but adds a newline.

Note: document.writeln (like document.write) does not work in XHTML documents (you'll get a "Operation is not supported" (NS_ERROR_DOM_NOT_SUPPORTED_ERR) error on the error console). This is the case if opening a local file with a .xhtml file extension or for any document served with an application/xhtml+xml MIME type. More information is available in the W3C XHTML FAQ.

Specification

writeln

{{ languages( { "ja": "ja/DOM/document.writeln", "pl": "pl/DOM/document.writeln" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Writes a string of text followed by a newline character to a document.</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval">
document.writeln(<em>line</em>); 
</pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<ul>
  <li><code>line</code> is string containing a line of text.</li>
</ul>
<h3 id="Example" name="Example">Example</h3>
<pre>
document.writeln("&lt;p&gt;enter password:&lt;/p&gt;"); 
</pre>
<h3 id="Notes" name="Notes">Notes</h3>
<p><strong>document.writeln</strong> is the same as <a href="/en/DOM/document.write" title="en/DOM/document.write">document.write</a> but adds a newline.</p>
<div class="note">
  <strong>Note:</strong> <strong>document.writeln</strong> (like <strong>document.write</strong>)&nbsp;does not work in XHTML&nbsp;documents (you'll get a "Operation is not supported" (<code>NS_ERROR_DOM_NOT_SUPPORTED_ERR</code>) error on the error console). This is the case if opening a local file with a .xhtml file extension&nbsp;or for any document served with an application/xhtml+xml MIME type. More information is available in the <a class="external" href="http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite" title="http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite">W3C XHTML&nbsp;FAQ</a>.</div>
<h3 id="Specification" name="Specification">Specification</h3>
<p><a class="external" href="http://www.w3.org/TR/2000/WD-DOM-Level-2-HTML-20001113/html.html#ID-35318390">writeln </a></p>
<p>{{ languages( { "ja": "ja/DOM/document.writeln", "pl": "pl/DOM/document.writeln" } ) }}</p>
Revert to this revision