代码示例:(标识:jsck_doc_write_7)
<!DOCTYPE html>
<html>
<body>

<h1>Document 对象</h1>

<h2>write() 方法</h2>

<p>如果想在 HTML 中换行,您必须使用段落或 br 标签:</p>

<script>
document.write("Hello World!");
document.write("<br>");
document.write("Have a nice day!");
</script>

</body>
</html>
运行结果: