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

<h1>Document 对象</h1>

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

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

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

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