forked from mislav/diveintohtml5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
everything.html
302 lines (227 loc) · 15.9 KB
/
everything.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html>
<meta charset=utf-8>
<title>The All-In-One Almost-Alphabetical No-Bullshit Guide to Detecting Everything - Dive Into HTML5</title>
<!--[if lt IE 9]><script src=j/html5.js></script><![endif]-->
<link rel=stylesheet href=screen.css>
<style>
h1:before{content:"Appendix A:"}
dd{padding-bottom:1.75em}
pre{margin:0;padding:0}
a.hl:link,a.hl:visited{color:#fff;padding-left:0.1em;text-decoration:none;border:0}
dt:hover a.hl{background:transparent;color:silver}
</style>
<link rel=stylesheet media='only screen and (max-device-width: 480px)' href=mobile.css>
<link rel=prefetch href=detect.html>
<p>You are here: <a href=index.html>Home</a> <span class=u>‣</span> <a href=table-of-contents.html#everything>Dive Into <abbr>HTML5</abbr></a> <span class=u>‣</span>
<h1><br>The All-In-One<br>Almost-Alphabetical<br>No-Bullshit Guide to<br>Detecting Everything</h1>
<p class=a>❧
<p>(Confused? Read <a href=detect.html>Detecting <abbr>HTML5</abbr> Features</a> for a conceptual introduction. Want an all-in-one library instead? Try <a href=http://modernizr.com/>Modernizr</a>.)
<dl>
<dt id=audio><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#audio"><code><audio></code></a>
<dd><code>return !!document.createElement('audio').canPlayType;</code>
<dt id=audio-mp3><a href=http://en.wikipedia.org/wiki/MP3><code><audio></code> in MP3 format</a>
<dd><pre><code>var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));</code></pre>
<dt id=audio-vorbis><a href=http://en.wikipedia.org/wiki/Vorbis><code><audio></code> in Vorbis format</a>
<dd><pre><code>var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, ''));</code></pre>
<dt id=audio-wav><a href=http://en.wikipedia.org/wiki/WAV><code><audio></code> in WAV format</a>
<dd><pre><code>var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/wav; codecs="1"').replace(/no/, ''));</code></pre>
<dt id=audio-aac><a href=http://en.wikipedia.org/wiki/Advanced_Audio_Coding><code><audio></code> in AAC format</a>
<dd><pre><code>var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/mp4; codecs="mp4a.40.2"').replace(/no/, ''));</code></pre>
<dt id=canvas><a href=canvas.html><code><canvas></code></a>
<dd><code>return !!document.createElement('canvas').getContext;</code>
<dt id=canvas-text><a href=canvas.html#text><code><canvas></code> text <abbr>API</abbr></a>
<dd><pre><code>var c = document.createElement('canvas');
return c.getContext && typeof c.getContext('2d').fillText == 'function';</code></pre>
<dt id=command><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-command><code><command></code></a>
<dd><code>return 'type' in document.createElement('command');</code>
<dt id=datalist><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-datalist-element><code><datalist></code></a>
<dd><pre><code>return 'options' in document.createElement('datalist');</code></pre>
<dt id=details><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-details-element><code><details></code></a>
<dd><code>return 'open' in document.createElement('details');</code>
<dt id=device><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#devices><code><device></code></a>
<dd><code>return 'type' in document.createElement('device');</code>
<dt id=novalidate><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#constraints><code><form></code> constraint validation</a>
<dd><code>return 'noValidate' in document.createElement('form');</code>
<dt id=sandbox><a href=http://blog.whatwg.org/whats-next-in-html-episode-2-sandbox><code><iframe sandbox></code></a>
<dd><code>return 'sandbox' in document.createElement('iframe');</code>
<dt id=srcdoc><a href=http://blog.whatwg.org/whats-next-in-html-episode-2-sandbox><code><iframe srcdoc></code></a>
<dd><code>return 'srcdoc' in document.createElement('iframe');</code>
<dt id=autofocus><a href=forms.html#autofocus><code><input autofocus></code></a>
<dd><code>return 'autofocus' in document.createElement('input');</code>
<dt id=placeholder><a href=forms.html#placeholder><code><input placeholder></code></a>
<dd><code>return 'placeholder' in document.createElement('input');</code>
<dt id=placeholder-textarea><a href=forms.html#placeholder><code><textarea placeholder></code></a>
<dd><code>return 'placeholder' in document.createElement('textarea');</code>
<dt id=input-color><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/number-state.html#color-state><code><input type="color"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'color');
return i.type !== 'text';</code></pre>
<dt id=input-email><a href=forms.html#type-email><code><input type="email"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'email');
return i.type !== 'text';</code></pre>
<dt id=input-number><a href=forms.html#type-number><code><input type="number"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'number');
return i.type !== 'text';</code></pre>
<dt id=input-range><a href=forms.html#type-range><code><input type="range"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'range');
return i.type !== 'text';</code></pre>
<dt id=input-search><a href=forms.html#type-search><code><input type="search"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'search');
return i.type !== 'text';</code></pre>
<dt id=input-tel><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#telephone-state><code><input type="tel"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'tel');
return i.type !== 'text';</code></pre>
<dt id=input-url><a href=forms.html#type-url><code><input type="url"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'url');
return i.type !== 'text';</code></pre>
<dt id=input-date><a href=forms.html#date><code><input type="date"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'date');
return i.type !== 'text';</code></pre>
<dt id=input-time><a href=forms.html#date><code><input type="time"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'time');
return i.type !== 'text';</code></pre>
<dt id=input-datetime><a href=forms.html#date><code><input type="datetime"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'datetime');
return i.type !== 'text';</code></pre>
<dt id=input-datetime-local><a href=forms.html#date><code><input type="datetime-local"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'datetime-local);
return i.type !== 'text';</code></pre>
<dt id=input-month><a href=forms.html#date><code><input type="month"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'month');
return i.type !== 'text';</code></pre>
<dt id=input-week><a href=forms.html#date><code><input type="week"></code></a>
<dd><pre><code>var i = document.createElement('input');
i.setAttribute('type', 'week');
return i.type !== 'text';</code></pre>
<dt id=meter><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-meter-element><code><meter></code></a>
<dd><code>return 'value' in document.createElement('meter');</code>
<dt id=output><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-output-element><code><output></code></a>
<dd><code>return 'value' in document.createElement('output');</code>
<dt id=progress><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-progress-element><code><progress></code></a>
<dd><code>return 'value' in document.createElement('progress');</code>
<dt id=time><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-time-element><code><time></code></a>
<dd><code>return 'valueAsDate' in document.createElement('time');</code>
<dt id=video><a href=video.html><code><video></code></a>
<dd><code>return !!document.createElement('video').canPlayType;</code>
<dt id=video-captions><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#websrt><code><video></code> captions</a>
<dd><code>return 'src' in document.createElement('track');</code>
<dt id=video-poster><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-video-poster"><code><video poster></code></a>
<dd><code>return 'poster' in document.createElement('video');</code>
<dt id=video-webm><a href=http://www.webmproject.org/><code><video></code> in WebM format</a>
<dd><pre><code>var v = document.createElement('video');
return !!(v.canPlayType && v.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/, ''));</code></pre>
<dt id=video-h264><a href=video.html#h264><code><video></code> in H.264 format</a>
<dd><pre><code>var v = document.createElement('video');
return !!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));</code></pre>
<dt id=video-theora><a href=video.html#theora><code><video></code> in Theora format</a>
<dd><pre><code>var v = document.createElement('video');
return !!(v.canPlayType && v.canPlayType('video/ogg; codecs="theora"').replace(/no/, ''));</code></pre>
<dt id=contenteditable><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable><code>contentEditable</code></a>
<dd><code>return 'isContentEditable' in document.createElement('span');</code>
<dt id=postmessage><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#web-messaging>Cross-document messaging</a>
<dd><code>return !!window.postMessage;</code>
<dt id=dnd><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd>Drag-and-drop</a>
<dd><code>return 'draggable' in document.createElement('span');</code>
<dt id=filereader><a href=http://dev.w3.org/2006/webapi/FileAPI/>File <abbr>API</abbr></a>
<dd><code>return typeof FileReader != 'undefined';</code>
<dt id=geolocation><a href=geolocation.html>Geolocation</a>
<dd><code>return !!navigator.geolocation;</code>
<dt id=history><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-history-interface>History</a>
<dd><code>return !!(window.history && window.history.pushState);</code>
<dt id=storage><a href=http://dev.w3.org/html5/webstorage/>Local storage</a>
<dd><pre><code>try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch(e) {
return false;
}</code></pre>
<dt id=microdata><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#microdata-dom-api>Microdata</a>
<dd><code>return !!document.getItems;</code>
<dt id=offline><a href=offline.html>Offline web applications</a>
<dd><code>return !!window.applicationCache;</code>
<dt id=eventsource><a href=http://dev.w3.org/html5/eventsource/>Server-sent events</a>
<dd><code>return typeof EventSource !== 'undefined';</code>
<dt id=session-storage><a href=http://dev.w3.org/html5/webstorage/>Session storage</a>
<dd><pre><code>try {
return 'sessionStorage' in window && window['sessionStorage'] !== null;
} catch(e) {
return false;
}</code></pre>
<dt id=svg><a href=http://www.w3.org/TR/SVG/><abbr>SVG</abbr></a>
<dd><code>return !!(document.createElementNS && document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect);</code>
<dt id=inline-svg><a href=http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/><abbr>SVG</abbr> in <code>text/html</code></a>
<dd><pre><code>var e = document.createElement('div');
e.innerHTML = '<svg></svg>';
return !!(window.SVGSVGElement && e.firstChild instanceof window.SVGSVGElement);</code></pre>
<dt id=undo><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#undo>Undo</a>
<dd><code>return typeof UndoManager !== 'undefined';</code>
<dt id=indexeddb><a href=http://www.w3.org/TR/IndexedDB/>IndexedDB</a>
<dd><code>return !!window.indexedDB;</code>
<dt id=websockets><a href=http://dev.w3.org/html5/websockets/>Web Sockets</a>
<dd><code>return !!window.WebSocket;</code>
<dt id=websql><a href=http://dev.w3.org/html5/webdatabase/>Web SQL Database</a>
<dd><code>return !!window.openDatabase;</code>
<dt id=workers><a href=http://www.whatwg.org/specs/web-workers/current-work/>Web Workers</a>
<dd><code>return !!window.Worker;</code>
<dt id=widgets><a href=http://www.w3.org/TR/widgets/>Widgets</a>: am I in one?
<dd><code>return typeof widget !== 'undefined';</code>
<dt id=xmlhttprequest-withcredentials><a href=http://www.w3.org/TR/XMLHttpRequest2/#the-withcredentials-attribute>XMLHttpRequest: cross-domain requests</a>
<dd><code>return "withCredentials" in new XMLHttpRequest;</code>
<dt id=xmlhttprequest-formdata><a href=http://www.w3.org/TR/XMLHttpRequest2/#the-formdata-interface>XMLHttpRequest: send as form data</a>
<dd><code>return !!window.FormData;</code>
<dt id=xmlhttprequest-upload><a href=http://www.w3.org/TR/XMLHttpRequest2/#the-upload-attribute>XMLHttpRequest: upload progress events</a>
<dd><code>return "upload" in new XMLHttpRequest;</code>
</dl>
<p class=a>❧
<h2 id=further-reading>Further Reading</h2>
<p>Specifications and standards:
<ul>
<li><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/><abbr>HTML5</abbr></a>
<li><a href=http://www.w3.org/TR/geolocation-API/>Geolocation</a>
<li><a href=http://dev.w3.org/html5/eventsource/>Server-Sent Events</a>
<li><a href=http://dev.w3.org/2006/webapi/WebSimpleDB/>WebSimpleDB</a>
<li><a href=http://dev.w3.org/html5/websockets/>Web Sockets</a>
<li><a href=http://dev.w3.org/html5/webdatabase/>Web SQL Database</a>
<li><a href=http://dev.w3.org/html5/webstorage/>Web Storage</a>
<li><a href=http://www.whatwg.org/specs/web-workers/current-work/>Web Workers</a>
<li><a href=http://www.w3.org/TR/widgets/>Widgets</a>
<li><a href=http://www.w3.org/TR/XMLHttpRequest2/>XMLHttpRequest Level 2</a>
</ul>
<p>JavaScript libraries:
<ul>
<li><a href=http://www.modernizr.com/>Modernizr</a>, an <abbr>HTML5</abbr> detection library
</ul>
<p class=a>❧
<p>This has been “The All-In-One Almost-Alphabetical No-Bullshit Guide to Detecting Everything.” The <a href=table-of-contents.html>full table of contents</a> has more if you’d like to keep reading.
<div class=pf>
<h4>Did You Know?</h4>
<div class=moneybags>
<blockquote><p>In association with Google Press, O’Reilly is distributing this book in a variety of formats, including paper, ePub, Mobi, and <abbr>DRM</abbr>-free <abbr>PDF</abbr>. The paid edition is called “HTML5: Up & Running,” and it is available now. This appendix is included in the paid edition.
<p>If you liked this appendix and want to show your appreciation, you can <a href="http://www.amazon.com/HTML5-Up-Running-Mark-Pilgrim/dp/0596806027?ie=UTF8&tag=diveintomark-20&creativeASIN=0596806027">buy “HTML5: Up & Running” with this affiliate link</a> or <a href=http://oreilly.com/catalog/9780596806033>buy an electronic edition directly from O’Reilly</a>. You’ll get a book, and I’ll get a buck. I do not currently accept direct donations.
</blockquote>
</div>
</div>
<p class=c>Copyright MMIX–MMXI <a href=about.html>Mark Pilgrim</a>
<script src=j/jquery.js></script>
<script src=j/dih5.js></script>
<script>
$('dt[id]').each(function() {
$('<a class=hl>#</a>').
attr('href', '#' + this.id).
appendTo(this);
});
</script>