Skip to Content


You (Level 0)
0% Complete
Last Badge Earned

The JavaScript navigator object is useful for customizing your JavaScript based on the user's browser and what they have enabled on that browser. Remember all browsers are different and handle JavaScript differently. For example, the user might not have cookies enabled, but has JavaScript enabled. Let's take a better look at what I am talking about through examples.

While I still express my rage for some browser incompatibility, it is much better than it used to be. This ultimately means that things like the navigator object are losing their importance. Back in the day, you would use the navigator object to structure you code. So, if the user was on internet explorer, use this code, but if they are on safari, use this code. The navigator is now more commonly used to track information about the user, which can also be attained by server-side programming languages adding to the lower importance of the navigator object.

Navigator Properties

  • appCodeName - gets the code name of the browser
  • appName - gets the name of the browser
  • appVersion - gets the version
  • cookieEnabled - tells us if cookies are enabled
  • platform - gets the browsers platform
  • userAgent - gets the header from the server request
Example <script type="text/javascript">
document.write(navigator.appCodeName + "<br>");
document.write(navigator.appName + "<br>");
document.write(navigator.appVersion + "<br>");
document.write(navigator.cookieEnabled + "<br>");
document.write(navigator.platform + "<br>");
document.write(navigator.userAgent + "<br>");
5.0 (Windows)
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.3) Gecko/20100101 Firefox/10.0.3

I don't usually deal with the navigator properties, unless I am setting JavaScript cookies or am gathering information about my user's browsers. Last, but not least, I will show you the only useful method in the navigator class.

  • javaEnabled() - tells us if Java is enabled
Example document.write(navigator.javaEnabled());

I've attached my favorite JavaScript and jQuery book. I would encourage you to read it as well.

Your code will execute in this window.

Let's explore some more tutorials or topics!

Next Tutorial Previous Tutorial


If you enjoyed this resource, support me by sharing this page with others.

Comment on

Show Comments

No comments yet... Be the first!