Bab 6: HTML5 APIs dan Advanced Features
Bab 6: HTML5 APIs dan Advanced Features
6.1 Storage APIs
6.1.1 LocalStorage
// Menyimpan data
localStorage.setItem('username', 'john_doe');
localStorage.setItem('preferences', JSON.stringify({
theme: 'dark',
fontSize: '16px'
}));
// Mengambil data
const username = localStorage.getItem('username');
const preferences = JSON.parse(localStorage.getItem('preferences'));
// Menghapus data
localStorage.removeItem('username');
// Menghapus semua data
localStorage.clear();
// Event listener untuk storage changes
window.addEventListener('storage', (e) => {
console.log('Storage changed:', e.key, e.newValue);
});6.1.2 SessionStorage
6.1.3 IndexedDB
6.1.4 Cache API
6.2 Drag and Drop
6.2.1 Draggable Elements
6.2.2 Drop Zones
6.2.3 File Drag and Drop
6.3 Geolocation dan Device APIs
6.3.1 Geolocation API
6.3.2 Device Orientation
6.3.3 Battery Status
6.3.4 Media Capture
Latihan Praktik
Latihan 1: Todo App dengan LocalStorage
Latihan 2: File Upload dengan Drag and Drop
Latihan 3: Location-based Service
Ringkasan Bab
Quiz Bab 6
Referensi
Last updated