Skip to content

Navigator object in JavaScript | API

  • by

The JavaScript navigator object is a property of the window object and contains browser information. You can use it to detect or get browser information such as appName, appCodeName, userAgent, etc.

The navigator object can be accessed by:


Navigator Object Properties

Here are the properties of the navigator object that returns information from the browser.

appCodeNameReturns browser code name
appNameReturns browser name
appVersionReturns browser version
cookieEnabledReturns true if browser cookies are enabled
geolocationReturns a geolocation object for the user’s location
languageReturns browser language
onLineReturns true if the browser is online
platformReturns browser platform
productReturns browser engine name
userAgentReturns browser user-agent header

Navigator Object Methods

Here are the methods of navigator objects.

javaEnabled()Returns true if the browser has Java enabled
taintEnabled()Removed in JavaScript version 1.2 (1999).

Navigator object in JavaScript

Simple example code.

<!DOCTYPE html>
      console.log("appCodeName: ", navigator.appCodeName);  
      console.log("appName: ", navigator.appName);  
      console.log("appVersion: ", navigator.appVersion);  
      console.log("cookieEnabled: ", navigator.cookieEnabled);  
      console.log("language: ", navigator.language);  
      console.log("userAgent: ", navigator.userAgent);  
      console.log("platform: ", navigator.platform);  
      console.log("onLine: ", navigator.onLine);  




These properties and methods can be useful for developing web applications that need to adapt their behavior based on the user’s browser environment. However, it’s important to note that the information provided by the Navigator object may not always be reliable, as user agents can be spoofed and certain features may not be available in all browsers.

Comment if you have any doubts or suggestions on this JS object topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *