Browser Information
Browser Information
Section titled “Browser Information”Introduction
Section titled “Introduction”The navigator object provides information about the browser, platform, and user’s language preferences.
Key Properties
Section titled “Key Properties”navigator.userAgent; // Browser user agent stringnavigator.platform; // Platform (e.g., 'Win32', 'MacIntel')navigator.language; // Browser language (e.g., 'en-US')navigator.languages; // Array of preferred languagesnavigator.onLine; // Online status (boolean)Online/Offline Detection
Section titled “Online/Offline Detection”// Check current statusif (navigator.onLine) { console.log('User is online');} else { console.log('User is offline');}
// Listen for changeswindow.addEventListener('online', () => console.log('Back online'));window.addEventListener('offline', () => console.log('Went offline'));Summary
Section titled “Summary”navigator.userAgent— browser identification (use with caution)navigator.language— preferred languagenavigator.onLine— online/offline status- Listen for
online/offlineevents for real-time connectivity