HTML - DOM Document writeln() Method



HTML DOM document writeln() method provides user the functionality to write multiple expressions (HTML or JavaScript) directly to a document. It deletes all the existing content of the document and writes new expressions to it.

This method is similar to write() method only difference being addition of a newline character after each statement.

Syntax

document.writeln(exp1, exp2,.....expN);

Parameter

This method accepts a single parameter as listed below.

Parameter Description
(exp1, exp2,..expN) It represents text, HTML or javascript codes which you want to insert in HTML document. These are displayed in the order of their occurrence.

Return Value

This method does not return anything.

Example of HTML DOM Document 'writeln()' Method

The following example illustrates writeln() method where a new text is inserted into an existing document.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>HTML DOM document writeln() Method</title>
</head>
<body>
    <pre>
<script>
    document.writeln("Welcome to Tutorials Point..");
    document.writeln("A new journey begins here ..");
</script>
</pre>
</body>
</html>

Supported Browsers

Method Chrome Edge Firefox Safari Opera
writeln() Yes 64 Yes 12 Yes 1 Yes 11 Yes 51
html_dom_document_reference.htm
Advertisements