<html>
<body>
<h1>Document 对象</h1>
<h2>open() 和 close() 方法</h2>
<p>单击“打开”打开此文档,向其中写入一些文本并关闭它:</p>
<button onclick="myFunction()">打开</button>
<script>
function myFunction() {
document.open();
document.write("<h1>Hello World</h1>");
document.write("<p>打开文档并覆盖其原始文档。</p>");
document.close();
}
</script>
</body>
</html>