ความคิดเห็น: การเรียนรู้ W3C เป็นวิธีตรวจสอบว่าเบราว์เซอร์ของคุณรองรับวิดีโอ HTML5 หรือไม่ ฉันจะแบ่งปันกับคุณที่นี่ ผู้ที่สนใจสามารถอ้างถึงได้ ฉันหวังว่ามันจะช่วยคุณได้
เมื่อเรียนรู้ HTML5 ฉันเห็นวิธีการตรวจสอบว่าเบราว์เซอร์ของคุณรองรับวิดีโอ HTML5 หรือไม่:
เอฟเฟกต์การทำงาน:
1. ทำงานใน EditPlus
2. ทำงานในเบราว์เซอร์ Chrome
-
ส่วนรหัส:
-
<! ductype html>
<html>
<script type = "text/javascript">
ฟังก์ชั่น checkvideo ()
-
if (!! document.createElement ('วิดีโอ'). canplaytype)
-
var vidTest = document.createElement ("วิดีโอ");
oggtest = vidtest.canplaytype ('วิดีโอ/ogg; codecs = "Theora, vorbis"');
ถ้า (! Oggtest)
-
h264test = vidTest.canplayType ('วิดีโอ/mp4; codecs = "avc1.42e01e, mp4a.40.2");
ถ้า (! H264Test)
-
document.getElementById ("CheckVideOresult"). innerhtml = "ขออภัยไม่มีการสนับสนุนวิดีโอ"
-
อื่น
-
ถ้า (H264Test == "อาจ")
-
document.getElementById ("CheckVideOsult"). innerHtml = "ใช่! สนับสนุนเต็ม!";
-
อื่น
-
document.getElementById ("CheckVideOresult"). innerHtml = "ดีการสนับสนุนบางอย่าง";
-
-
-
อื่น
-
ถ้า (Oggtest == "อาจ")
-
document.getElementById ("CheckVideOsult"). innerHtml = "ใช่! สนับสนุนเต็ม!";
-
อื่น
-
document.getElementById ("CheckVideOresult"). innerHtml = "ดีการสนับสนุนบางอย่าง";
-
-
-
อื่น
-
document.getElementById ("CheckVideOresult"). innerhtml = "ขออภัยไม่มีการสนับสนุนวิดีโอ"
-
-
</script>
<body>
<p> การตรวจจับว่าเบราว์เซอร์ของคุณรองรับวิดีโอ HTML5 หรือไม่: </p>
<div>
<button> ตรวจสอบ </button>
</div>
</body>
</html>