--- title: document.writeln slug: Web/API/Document/writeln translation_of: Web/API/Document/writeln ---

{{ ApiRef() }}

概述

向文档中写入一串文本,并紧跟着一个换行符。

语法

document.writeln(line);

参数

示例

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

备注

document.writelndocument.write 一样,但是会添加一个换行符。

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.

规范

writeln

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