EDIT I have changed some Javascript now, so if I can find a javascript function that detects HTML5 Video support, it should work.
I have a HTML5 video player that has flash fallback, if HTML5 isnt supported, I want it to fallback to flash. Im currently using
<!--[if !IE]><!--> then load my custom player else use SWFObject to render it.
Is it possible to do the folllowing:
` If (HTML5 supported browser) { <some html and script> (My custom player) }else{ <different html and script> (I would call SWFobject here) } `
Trying to find a nice easy solution idea.
Usually I would be able to have an additional <object>
in the video tag, but this won't be possible due to the way the player is inserted into the page.
Even though I can detect HTML5 support with a possibly unreliable method, I'm not sure how to have my HTML based on the output of the support
The getContext method is checked by accessing it on the created input object. The result of this expression is checked with an if-statement. If the result is true, it means that HTML5 is supported by the browser.
To confirm if a webpage is HTML5 or 4.01, check the doctype at the very top of the webpage in source code view. Responsive (HTML5): Current code: Open one of your webpages in your browser (IE, Chrome, Edge, Safari), narrow the browser to around 320 pixels wide.
Have you had a look at http://www.modernizr.com/docs/#features-css
It can do feature detection
The better solution is to use something like Modernizr to do your feature detection on the client-side.Modernizr is an open source, MIT-licensed JavaScript library that detects support for many HTML5 & CSS3 features. If your browser does not support the canvas API, the Modernizr.canvas property will be false.
if (Modernizr.canvas) { // let's draw some shapes! } else { // no native canvas support available :( }
Ref
Another solution if you are using JQuery: Checking for support for the canvas element of HTML 5
var test_canvas = document.createElement("canvas") //try and create sample canvas element var canvascheck=(test_canvas.getContext)? true : false //check if object supports getContext() method, a method of the canvas element alert(canvascheck) //alerts true if browser supports canvas element
Ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With