案例:javascript案例     状态:可编辑再运行    进入横版
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h3>演示如何创建 SCRIPT 元素</h3>
6
7
<p>点击按钮来创建输出 "Hello World!" 的 SCRIPT 元素。</p>
8
9
<button onclick="myFunction()">试一下</button>
10
11
<script>
12
function myFunction()
13
{
14
var x = document.createElement("SCRIPT");
15
var t = document.createTextNode("alert('Hello World!')");
16
x.appendChild(t);
17
document.body.appendChild(x);
18
}
19
</script>
20
21
</body>
22
</html>
23

 运行结果 
 北美留学生论坛