Loading

Navigator Object

  • In JavaScript, the navigator object is part of the Browser Object Model (BOM) and provides information about the user's web browser and the user's system.
  • It contains many properties that provide details about the browser's capabilities, including its name, version, platform, and more. 

Properties:

navigator.userAgent:

  •  Returns a string that represents the user agent of the browser.

navigator.appName

  • Provides the name of the browser. 

navigator.appVersion:

  •  Returns the version of the browser.

navigator.platform:

  •  Indicates the operating system  on which the browser is running.

navigator.onLine:

 A Boolean value that indicates whether the browser is currently online or offline.


Methods:

navigator.geolocation:

  •  This property allows you to access the user's geographical location if the browser supports the Geolocation API.

navigator.getBattery():

  •  This method provides information about the device's battery status and allows you to monitor its charge level and status.

Example:

<html>

<body>
    <h2>JavaScript Navigator Object</h2>
    <script>
        document.writeln("<br/>navigator.appCodeName: " + navigator.appCodeName);
        document.writeln("<br/>navigator.appName: " + navigator.appName);
        document.writeln("<br/>navigator.appVersion: " + navigator.appVersion);
        document.writeln("<br/>navigator.cookieEnabled: " + navigator.cookieEnabled);
        document.writeln("<br/>navigator.language: " + navigator.language);
        document.writeln("<br/>navigator.userAgent: " + navigator.userAgent);
        document.writeln("<br/>navigator.platform: " + navigator.platform);
        document.writeln("<br/>navigator.onLine: " + navigator.onLine);

    </script>
</body>

</html>

Output:
navigator.appCodeName: Mozilla
navigator.appName: Netscape
navigator.appVersion: 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
navigator.cookieEnabled: true
navigator.language: en-IN
navigator.userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
navigator.platform: Win32
navigator.onLine: true