Flat Preloader Icon

Navigator Object

The navigator object in JavaScript provides information about the web browser environment in which the script is running. It contains various properties and methods that allow you to access details such as the user’s browser, operating system, and capabilities. 

Property of JavaScript navigator object

Table with 2 Columns and 12 Rows
Property Description
appName returns the name
appVersion returns the version
appCodeName returns the code name
cookieEnabled returns true if cookie is enabled otherwise false
userAgent returns the user agent
language returns the language. It is supported in Netscape and Firefox only.
userLanguage returns the user language. It is supported in IE only.
plugins returns the plugins. It is supported in Netscape and Firefox only.
systemLanguage returns the system language. It is supported in IE only.
platform returns the platform e.g. Win32.
online returns true if browser is online otherwise false.
The navigator object in JavaScript provides information about the user’s browser and operating system. It contains properties that give details such as the browser name, version, platform, and whether cookies are enabled. Here’s a simple example demonstrating the usage of the navigator object:
				
					// Check if cookies are enabled
if (navigator.cookieEnabled) {
    console.log("Cookies are enabled.");
} else {
    console.log("Cookies are not enabled.");
}

// Display browser information
console.log("Browser Name: " + navigator.appName);
console.log("Browser Version: " + navigator.appVersion);
console.log("User Agent: " + navigator.userAgent);
console.log("Platform: " + navigator.platform);
console.log("Language: " + navigator.language);

				
			

Methods:

  • navigator.getBattery():

    • Returns a promise that resolves with a BatteryManager object representing the battery status of the device (if available).
  • navigator.vibrate():

    • Vibrates the device for a specified duration (if supported).
  • navigator.share():

    • Shares data (such as text, links, and files) to other apps or services on the device (if supported).