<html>
<body>
<script type="text/javascript">
window.onload = function(){
document.write("<h1>1</h1>");
}
document.write("<h1>2</h1>");
</script>
</body>
</html>
这种情况下后面的document.write("
<html>
<body>
<script type="text/javascript">
window.onload = function(){
document.write("<h1>1</h1>");
}
document.write("<h1>2</h1>");
</script>
</body>
</html>
这种情况下后面的document.write("
不要再文档流关闭后调用document.write,这个输出会覆盖当前页面的内容,改用innerHTML或者DOM的api来操作
document.body.innerHTML+='<h1>1</h1>'