This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Document.writeln()

Deprecated

Avoid using this feature in new projects. The dynamic markup insertion API, which includes document.write(), has "very idiosyncratic behavior" which can be difficult to debug. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: DOM.

Выводит в документ строку со знаком перевода каретки в конце.

Синтаксис

document.writeln(line);

Параметры

  • line - строка содержащая текст.

Пример

document.writeln("<p>введите пароль:</p>");

Примечания

document.writeln тоже самое, что document.write но добавляет знак новой строки.

Примечание: document.writeln (как и document.write) не работает с XHTML документами (вы получите ошибку "Operation is not supported" (NS_ERROR_DOM_NOT_SUPPORTED_ERR) в консоли ошибок). Происходит это, если открыть локальный файл с расширением .xhtml или документ с MIME типом application/xhtml+xml. Больше информации доступно на W3C XHTML FAQ.

Спецификации

writeln