This document discusses HTML5 features including new semantic elements, DOCTYPE declarations, feature detection methods, and Canvas, Video, Audio, Geolocation features. It covers HTML5 features like Canvas, Video, Audio, local storage, offline apps, and introduces new semantic elements. It also discusses various methods of feature detection including checking for properties, testing element properties, and type checking.
1 of 18
More Related Content
HTML5 Google Dev Groups 2013 - Jogja Digital Valley
4. Semantik - DOCTYPE
jaman kegelapan :
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
jaman pencerahan :
<!DOCTYPE html>
5. Semantik - Element Baru
<section> <nav> <article>
<aside> <hgroup> <header>
<footer> <time> <mark>
6. Semantik - Contoh
HTML4
HTML5
<div class="entry">
<p class="post-date">
October 22, 2009
</p>
<h1>
<a href="#"
rel="bookmark"
title="link to this post">
Travel day
</a>
</h1>
<p>Lorem ipsum dolor sit amet¡</p>
</div>
<article>
<header>
<time datetime="2009-10-22" pubdate>
October 22, 2009
</time>
<h1>
<a href="#"
rel="bookmark"
title="link to this post">
Travel day
</a>
</h1>
</header>
<p>Lorem ipsum dolor sit amet¡</p>
</article>
9. Metode Deteksi Fitur (1 / 4)
Cek jika properti eksis di dalam global object (navigator
atau window)
Tanpa Modernizr
function supports_geolocation() {
return 'geolocation' in navigator;
}
Modernizr
if (Modernizr.geolocation) {
// code..
} else {
// pake third party library
}
10. Metode Deteksi Fitur (2 / 4)
Ciptakan sebuah element, kemudian cek apakah suatu
properti eksis didalam element tersebut
Tanpa Modernizer
function supports_canvas() {
return !!document.createElement('canvas').getContext;
}
Modernizr
if (Modernizr.canvas) {
// code..
} else {
// canvas tidak didukung
}
11. Metode Deteksi Fitur (3 / 4)
Ciptakan element, cek apakah suatu method eksis, cek
kembalian
Tanpa Modernizer
function supports_h264_baseline_video() {
if (!supports_video()) { return false; }
var v = document.createElement("video");
return v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
}
Modernizr
if (Modernizr.video) {
if (Modernizr.video.webm) {
} else if (Modernizr.video.ogg) {
} else if (Modernizr.video.h264){
}
}
12. Metode Deteksi Fitur (4 / 4)
Ciptakan element, set properti dengan nilai tertentu, cek
tipe value tersebut
Tanpa Modernizer
var i = document.createElement("input");
i.setAttribute("type", "color");
return i.type !== "text";
Modernizr
if
}
(!Modernizr.inputtypes.date) {
13. Modernizr Polyfill
Replika standar API untuk browser
Daftar Polyfill
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills
Modernizr.load({
test: Modernizr.geolocation,
yep : 'geo.js',
nope: 'geo-polyfill.js'
});