<div>
我是div,哈哈哈
</div>
<script>
// 问题 任何时候使用document.write,页面会不会被清空?
// document.write(111);
// document.write(222);
// // 1 这种情况是可以打印出来,页面当前的内容不会被清空
// window.onload = function () {
// document.write(111);
// document.write(222);
// }
//2 两次document.write()的内容会被打印出来,页面当前的内容会被清空
// 其实在执行window.onload之前.浏览器了创建文档流 ---> 然后这时候再执行window.onload函数,
// 而执行document.write()函数会自动调用document.open()函数,创建一个新的文档流,写入新的内容,就会覆盖原来的内容
// window.onload = function () {
// document.write(111);
// document.close(); //只能关闭由document.open()创建的文档流,
// document.write(222);
// //3 如果document.close()函数执行关闭,document.write()函数是执行了一次document.open()
// // 所以只输出222
// }
// document.close();
// document.write(111);
// document.write(222);
// 问题window.onload执行页面当前的内容会不会被清空
// window.onload = function () {
// document.close();
// document.write(111);
// document.write(222);
// }