复制代码代码如下: function checkVideo() { if(!!document.createElement(video).canPlayType) { //创建video元素 var vidTest=document.createElement("video"); //检测是否可以播放ogg格式的视频 oggTest=vidTest.canPlayType(video/ogg; codecs="theora, vorbis"); if (!oggTest) { //检测是否可以播放MP4格式的视频 h264Test=vidTest.canPlayType(video/mp4; codecs="avc1.42E01E, mp4a.40.2"); if (!h264Test) { document.getElementById("checkVideoResult").innerHTML="Sorry. No video support." } else { if (h264Test=="probably") { document.getElementById("checkVideoResult").innerHTML="Yes! Full support!"; } else { document.getElementById("checkVideoResult").innerHTML="Well. Some support."; } } } else { if (oggTest=="probably") { document.getElementById("checkVideoResult").innerHTML="Yes! Full support!"; } else { document.getElementById("checkVideoResult").innerHTML="Well. Some support."; } } } else { document.getElementById("checkVideoResult").innerHTML="Sorry. No video support." } }