Navigator

JavaScript Navigator property is a build in JS object having information of browser, OS, device etc. navigator.usergent can give information regarding Operating System, OS Version, device, browser name and version etc.


    window.navigator;

JS navigator Properties and methods


userAgent

navigator.userAgent property returns information of user's device, including HTML Version, Operation System, OS Version, Browser name, browser version, browser layout engine etc. See example


    navigator.userAgent;

appName

navigator.appName property returns the name of browser. All HTML5 based browsers returns Netscape. See example


    navigator.appName

appVersion

navigator.appVersion property returns version of web browser. In HTML5 based browsers, the first value in string, i.e 5.0 is version of HTML and then followed by OS information. See example


    navigator.appVersion;

platform

navigator.platform property returns the platform of browser. For Mac OS, it is "MacIntel". See example


    navigator.platform

language

navigator.language property returns language of web browser. See example


    navigator.language;

onLine

navigator.onLine property returns boolean value true if system is connected to network. If not connected, false will be returned.


    navigator.onLine;

vibrate

navigator.vibrate method can vibrate your smartphone with n no of milliseconds. n parameter in vibrate method is no of milliseconds. See example




    navigator.vibrate(100);    // vibrate for 0.1 sec
    navigator.vibrate(500);    // vibrate for 0.5 sec
    navigator.vibrate(1000);    // vibrate for 1 sec
    navigator.vibrate(2000);    // vibrate for 2 sec

getBattery

getBattery is obsolete feature used to get battery related information from system. This feature is no longer supported.


if(navigator.getBattery){
navigator.getBattery().then(function(x){ console.log(x.level)});
navigator.getBattery().then(function(x){ console.log(x.dischargingTime)});
}
else{
console.log("Battery Api Not Supported")
}

Battery Indicator

This is the battery level indicator of your system based on battery api and HTML5 Meter Element.


getLocation

navigator.getLocation method is used to get geolocation information of user. This article is already published in HTML5. Click below for Geolocation API