HTML DOM writeln() 方法
实例
write() 和 writeln() 之间的区别:
<body>
<p>Note that write() does NOT add a new line after each statement:</p>
<pre>
<script>
document.write("Hello World!");
document.write("Have a nice day!");
</script>
</pre>
<p>Note that writeln() add a new line after each statement:</p>
<pre>
<script>
document.writeln("Hello World!");
document.writeln("Have a nice day!");
</script>
</pre>
</body>
亲自试一试 »
<p>Note that write() does NOT add a new line after each statement:</p>
<pre>
<script>
document.write("Hello World!");
document.write("Have a nice day!");
</script>
</pre>
<p>Note that writeln() add a new line after each statement:</p>
<pre>
<script>
document.writeln("Hello World!");
document.writeln("Have a nice day!");
</script>
</pre>
</body>
定义和用法
writeln() 方法与 document.write() 方法相同,只是在每条语句后添加了一个换行符。
浏览器支持
方法 | |||||
---|---|---|---|---|---|
writeln() | Yes | Yes | Yes | Yes | Yes |
语法
document.writeln(exp1, exp2, exp3, ...)
参数值
参数 | 描述 |
---|---|
exp1, exp2, exp3, ... | 可选。写入输出流的内容。可以列出多个参数,并按出现顺序将它们附加到文档中 |
技术细节
返回值: | 无返回值 |
---|
❮ Document 对象