10 Navigator Object Properties in JavaScript

10 Navigator Object Properties in JavaScript

ยท

2 min read

In this blog post, we will look at 10 different navigator object properties in javascript. The navigator object consists information about the browser. There is no public standard that applies to the navigator object, but all major browsers support it.

So let's get started,

๐Ÿ”ท APPCODENAME

The appCodeName property returns the code name of the browser.

var x = "Browser CodeName: " + navigator.appCodeName;

console.log(x);
// output
// Browser CodeName: Mozilla

๐Ÿ”ท APPVERSION

The appVersion property returns the version information of the browser.

var x = "Version Info: " + navigator.appVersion;

console.log(x);
// output
// Version Info: 5.0 (Macintosh; Intel Mac OS X11_2_2) 
// AppleWebKit/537.36 (KHTML, Like Gecko) Chrome/88.0.192 Safari/537.36

๐Ÿ”ท GEOLOCATION

The geolocation property returns a Geolocation object that can be used to locate the user's position.

navigator.geolocation.getCurrentPosition(showPosition);
function showPosition(position) {
    console.log(position);
}

Output :- Screenshot (574).png

๐Ÿ”ท APPNAME

The appName property returns the name of the browser.

var x = "Browser Name: " + navigator.appName;

console.log(x);
// output
// Browser Name: Netscape

๐Ÿ”ท COOKIEENABLED

The cookieEnabled property returns a Boolean value that specifies whether cookies are enabled in the browser.

var x = "Cookies Enabled: " + navigator.cookieEnabled;

console.log(x);
// output
// Cookies Enabled: true

๐Ÿ”ท LANGUAGE

The language property returns the language version of the browser.

var x = "Language of the browser: " + navigator.language;

console.log(x);
// output
// Language of the browser: en-US

๐Ÿ”ท ONLINE

The onLine property returns a boolean value that specifies whether the browser is in online or offline mode.

var x = "Is the browser online? " + navigator.onLine;

console.log(x);
// output
// Is the browser online? true

๐Ÿ”ท USERAGENT

The userAgent property returns the value of the user-agent header sent by the browser to the server.

var x = "User-agent header sent: " + navigator.userAgent;

console.log(x);
// output
// User-agent header sent: Mozilla/5.0(Macintosh; Intel Mac X 11_2_2)
// AppleWebKit/537.36 (KHTML, like Gecko)
// Chrome/88.0.4324.192 Safari/537.36

๐Ÿ”ท PRODUCT

The product property returns the engine (product) name of the browser.

var x = "Browser's Engine Name: " + navigator.product;

console.log(x);
// output
// Browser's Engine Name: Gecko

๐Ÿ”ท PLATFORM

The platform property returns for which platform the browser is compiled.

var x = "Platform: " + navigator.platform;

console.log(x);
// output
// Platform: MacIntel

Hope you liked this!

Let's Get Connected ๐Ÿค:)

ย