案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h3>演示如何创建 VIDEO 元素</h3>
6
7
<p>请点击按钮来创建 VIDEO 元素,该元素将播放 .ogg 文件格式的影片。</p>
8
9
<button onclick="myFunction()">试一下</button>
10
11
<p id="demo"></p>
12
13
<script>
14
function myFunction()
15
{
16
var x = document.createElement("VIDEO");
17
x.setAttribute("width", "320");
18
x.setAttribute("height", "240");
19
x.setAttribute("controls", "controls");
20
x.setAttribute("src", "/img/movie.mp4");
21
document.body.appendChild(x);
22
document.getElementById("demo").innerHTML = "<b>注释:</b>IE 和 Safari 不支持 .ogg 文件格式。这只是一个例子。如需使其在所有浏览器中运行,您应该在 video 元素中使用 source 元素。";
23
}
24
</script>
25
26
</body>
27
</html>