案例:html/html5 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html> 
2
<html> 
3
<body> 
4
5
<p>我的浏览器能够播放 MP4 视频吗?<span>
6
<button onclick="supportType(event,'video/mp4','avc1.42E01E, mp4a.40.2')" type="button">测试</button>
7
</span></p>
8
9
<p>我的浏览器能够播放 OGG 视频吗?<span>
10
<button onclick="supportType(event,'video/ogg','theora, vorbis')" type="button">测试</button>
11
</span></p>
12
13
<script> 
14
function supportType(e,vidType,codType)
15
  { 
16
  myVid=document.createElement('video');
17
  isSupp=myVid.canPlayType(vidType+';codecs="'+codType+'"');
18
  if (isSupp=="")
19
    {
20
    isSupp="No";
21
    }
22
  e.target.parentNode.innerHTML="Answer: " + isSupp;
23
  } 
24
</script> 
25
</body> 
26
</html>
27