댓글 : W3C 학습은 브라우저가 HTML5 비디오를 지원하는지 여부를 감지하는 방법입니다. 여기서 당신과 공유하겠습니다. 관심있는 사람들은 그것을 언급 할 수 있습니다. 나는 그것이 당신을 도울 수 있기를 바랍니다.
HTML5를 학습 할 때 브라우저가 HTML5 비디오를 지원하는지 여부를 감지하는 방법을 보았습니다.
실행 효과 :
1. EditPlus에서 실행하십시오
2. 크롬 브라우저에서 실행하십시오
====================================================================================
코드 섹션 :
====================================================================================
<! ductype html>
<html>
<script type = "text/javaScript">
함수 checkVideo ()
{
if (!! document.createelement ( 'video'). canplayType)
{
var vidtest = document.createElement ( "비디오");
OggTest = vidTest.canplayType ( 'video/ogg; codecs = "theora, vorbis"');
if (! oggtest)
{
h264test = vidtest.canplaytype ( 'video/mp4; codecs = "avc1.42e01e, mp4a.40.2"');
if (! h264test)
{
document.getElementById ( "CheckVideOresult"). innerHtml = "죄송합니다. 비디오 지원이 없습니다."
}
또 다른
{
if (h264test == "아마")
{
document.getElementById ( "CheckVideOresult"). innerhtml = "예! 전체 지원!";
}
또 다른
{
document.getElementById ( "CheckVideOresult"). innerHtml = "음. 약간의 지원.";
}
}
}
또 다른
{
if (oggtest == "아마")
{
document.getElementById ( "CheckVideOresult"). innerhtml = "예! 전체 지원!";
}
또 다른
{
document.getElementById ( "CheckVideOresult"). innerHtml = "음. 약간의 지원.";
}
}
}
또 다른
{
document.getElementById ( "CheckVideOresult"). innerHtml = "죄송합니다. 비디오 지원이 없습니다."
}
}
</스크립트>
<body>
<p> 브라우저가 HTML5 비디오를 지원하는지 여부 : </p>
<div>
<버튼> 점검 </button>
</div>
</body>
</html>