DEV Community

Cover image for Using the Navigator object!!!
shikhar sharma
shikhar sharma

Posted on

Using the Navigator object!!!

In this blog post i am going to talk about the navigator object. First thing first, what is navigator object???
It is simply a container object that provides us with a whole lot of browser specific information. The browser used by the client to access any page on the web has a lot of information related to itself. While making web apps one can find a lot of scenarios where that browser specific information is needed.

The navigator object can be retrieved by using the read-only window.navigator property.

general syntax

var navObject = window.navigator;
Enter fullscreen mode Exit fullscreen mode

this simply assign the window.navigator to a variable which can further be used as follows...

checking the userAgent

var uA = navObject.userAgent;
console.log("User Agent:",uA);
// output: User Agent: "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725  Netscape6/6.1"
Enter fullscreen mode Exit fullscreen mode

We will now discuss what does these properties do along with other methods of navigator object.
These properties and methods are standard and are widely implemented in most web apps in one way or another.

Navigator properties

=> appCodeName : Returns the code name of the browser
=> appName Returns the name of the browser
=> appVersion : Returns the version information of the browser
=> cookieEnabled : Determines whether cookies are enabled in the
browser
=> geolocation : Returns a Geolocation object that can be used to
locate the user's position
=> language : Returns the language of the browser
=> onLine : Determines whether the browser is online
=> platform : Returns for which platform the browser is compiled

=> product : Returns the engine name of the browser
=> userAgent : Returns the user-agent header sent by the browser
to the server

Navigator methods

=> javaEnabled() : Specifies whether or not the browser has Java enabled
=> taintEnabled() : Removed in JavaScript version 1.2. Specifies whether the browser has data tainting enabled

These properties and methods returns strings or boolean data.

The navigator object has some more properties other than the onse mentioned above, to check all the properties kindly refer to other resources on the web. Navigator object does not have any public standards and sometimes the information we get from it is incorrect, there might be some people who questions its overall reliability but it is a little feature which is very usefull and is widely accepted by all the mainstream browsers.

There are a lot of resources on the internet from where you can read about the navigator object....

feel free to comment, suggest corrections or have discussions regarding the same!!!!

GO CODING!!!!

Top comments (0)