0
var isH5 = !! document.createElement('canvas').getContext

Would you say, that above JS code snippet is a good method of recognising a Browser's HTML5 capability?

Also see What is the !! (not not) operator in JavaScript? in case of IE quirks mode, it should still return false.

Update: Thanks for all the Modernizr links, we are using above recognising logic in conjunction with Modernizr already.

Community
  • 1
  • 1
Stephan Kristyn
  • 15,015
  • 14
  • 88
  • 147

1 Answers1

1

The better solution is to use something Modernizr to detection .Modernizr is an open source, MIT-licensed JavaScript library that detects support for many HTML5 & CSS3 features. If there isnt support, it returns false

if (Modernizr.canvas) {
  // logic
} else {
  // your message
}
AngularLover
  • 364
  • 1
  • 12