案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p>
6
JavaScript 能够直接写入 HTML 输出流中:
7
</p>
8
9
<script>
10
document.write("<h1>This is a heading</h1>");
11
document.write("<p>This is a paragraph.</p>");
12
</script>
13
14
<p>
15
您只能在 HTML 输出流中使用 <strong>document.write</strong>
16
如果您在文档已加载后使用它(比如在函数中),会覆盖整个文档。
17
</p>
18
19
</body>
20
</html>
21