<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>用JavaScript檢測視頻格式支持</title> <script type="text/javascript"> function checkVideo() { var myVideo = document.createElement('video'); if (myVideo.canPlayType) { if ("" != myVideo.canPlayType('video/mp4;codecs="avc1.64001E"')) { document.write("您的瀏覽器支持h264編碼。<br>"); } if ("" != myVideo.canPlayType('video/ogg; codecs="vp8"')) { document.write("您的瀏覽器支持vp8編碼。<br>"); } if ("" != myVideo.canPlayType('video/ogg; codecs="theora"')) { document.write("您的瀏覽器支持theora編碼。"); } } else { document.write("您的瀏覽器不支持要檢測的視頻格式。"); } } window.onload = function () { checkVideo(); } </script> </head> <body> </body> </html>