tutorialstonight logo


Javascript BOM : Navigator Object

The Javascript Navigator is an object of window interface, it provides information about the web browser and its capabilities.

The Navigator object can be accessed using window.navigator or simply navigator because window is a global object.

The types of information that can be retrieved using navigator objects are :

  • Weather user is online
  • Operating user is using (platform)
  • Browser user is using
  • Browser Version
  • Weather Cookies are enabled or not
  • Browser Language
  • And many more...

javascript detect online offline

We can check the internet connection status of the browser and can tell whether the browser is online or offline.

To check the online status of browsers use navigator.online, it returns boolean value. It will return true if the user is online and false if the user is offline.

navigator.online is not trustable, in some cases it always returns true. Refer MDN for browser compatibility

Detect Operating System in Javascript

To get the operating system of a user you can use platform as well as appVersion. Both properties result in the operating system of the user in different formats.

Don't rely on these properties to always return the correct result.

Get Browser Name and Version using Javascript

Using the navigator object we can access many information related to the browser.

  • appName - Returns name of browser
  • appCodeName - Returns code name of the browser
  • userAgent - Returns user agent string for current browser. It includes all information regarding browser and operating system

Check Cookie Enabled Javascript

To check whether cookie is enabled or not use cookieEnabled property. It returns boolean value true if cookie is enabled and false if cookie is disabled.

Check Language

To get the language of a webpage use the language property of the navigator object. While there is another property languages which returns value in array.

Javascript Location