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...
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.onlineis not trustable, in some cases it always returns true. Refer MDN for browser compatibility
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.
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
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.
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.