Check whether the browser supports html5 video code

Source: Internet
Author: User

Comments: Learning w3c is to see a method to check whether your browser supports HTML5 videos. I would like to share with you here. If you are interested, please refer to it and hope to help you.

When learning html5 in http://www.w3school.com.cn, see a method to check whether your browser supports HTML5 video:

Running effect:

1. Run in EditPlus

2. Run in chrome

========================================================== ====================

Code Section:

========================================================== ====================

The Code is as follows:
<! Ductype html>
<Html>
<Script type = "text/javascript">
Function checkVideo ()
{
If (!! Document. createElement ('video'). canPlayType)
{
Var vidTest = document. createElement ("video ");
OggTest = vidTest. canPlayType ('video/ogg; codecs = "theora, vorbis "');
If (! OggTest)
{
Hsf-test = vidTest. canPlayType ('video/mp4; codecs = "avc1.42E01E, mp4a. 40.2 "');
If (! Hsf-test)
{
Document. getElementById ("checkVideoResult"). innerHTML = "Sorry. No video support ."
}
Else
{
If (hsf-test = "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 ."
}
}
</Script>
<Body>
<P> check whether your browser supports HTML5 videos: </p>
<Div id = "checkVideoResult" style = "margin: 10px 0 0 0; border: 0; padding: 0;">
<Button onclick = "checkVideo ()" style = "font-family: Arial, Helvetica, sans-serif;"> Check </button>
</Div>
</Body>
</Html>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.