navigator in javascript

The window.navigator object contains information about the visitor’s browser.

Window Navigator

The window.navigator object can be written without the window prefix.

//Example

navigator.appName
navigator. appCodeName
navigator.platfornm

Browser Platform

const platform = navigator.platform
console.log(platform) //MacIntel

Browser Language

const language navigator.language 
console.log(language) // ["en-GB", "en-US", "en"]

Is The Browser Online?

const onLine navigator.onLine
console.log(onLine) // true

Warning !!!

The information from the navigator object can often be misleading, and should not be used to detect browser versions because:

Different browsers can use the same name The navigator data can be changed by the browser owner Some browsers misidentify themselves to bypass site tests Browsers cannot report new operating systems, released later than the browser.


Browser Cookies

const isCookieEnabled = navigator.cookieEnabled
console.log(isCookie Enabled) //true

Browser Application Name

const appName = navigator.appNane 
console. log(appNane) //Netscape

//Strange enough, "Netscape" is the application name for both IE11, Chrome, Firefox, and Safari.

Browser Application Code Name

const appCodeName = navigator.appCodeName
console. log(appCodeName) //Mozilla

//Mozilla is the application code name for both Chrome, Firefox, IE, Safari, and Opera

Browser Engine

const product navigator.product 
console.log(product) //Gecko 

//Do not rely on this. Most browsers returns "Gecko" as product name

Browser Version

const appVersion navigator.appVersion 
console.log(appVersion) //"5.0 (Macintosh Intel Mac Os x 10_13_6) ApplewebKit/537.36

Browser Agent

const userAgent navigator.userAgent
console. 1log (userAgent) "Mozilla/5.0 (Macintosh; Intel Mac 10_13_6) AppleWebKit/537.36

Leave a Reply

Your email address will not be published.

Recent post

Redux to a Next JS App
Redux to a Next JS App
  • July 16, 2021
How to Create Objects In JavaScript
How to Create Objects In JavaScript?
  • June 29, 2021
HTML forms
HTML Forms
  • June 23, 2021
Need a successful project?

Lets Work Together

Estimate Project
  • right image
  • Left Image