This is a mirror of official site: http://jasper-net.blogspot.com/

Appendix A: The all-in-one almost alphabetical no-bullshit guide to detect everything

| Monday, May 17, 2010
Confused? Read Detecting HTML5 Features for a conceptual introduction. Want an all-in-one library instead? Try Modernizr.)

<audio>
return !!document.createElement('audio').canPlayType;

<audio> in MP3 format
var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));

<audio> in Vorbis format
var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, ''));

<audio> in WAV format
var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/wav; codecs="1"').replace(/no/, ''));

<audio> in AAC format
var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/mp4; codecs="mp4a.40.2"').replace(/no/, ''));

<canvas>
return !!document.createElement('canvas').getContext;

<canvas> text API
var c = document.createElement('canvas');
return c.getContext && typeof c.getContext('2d').fillText == 'function';

<command>
return 'type' in document.createElement('command');

<datalist>
return 'options' in document.createElement('datalist');

<details>
return 'open' in document.createElement('details');

<device>
return 'type' in document.createElement('device');

<form> constraint validation
return 'noValidate' in document.createElement('form');

Read more: Dive Into HTML5

Posted via email from jasper22's posterous

0 comments: