Monday , 20 November 2017
Home / Programming / JavaScript / Navigator Object – Advanced JavaScript Tutorial
Navigator Object
Navigator Object

Navigator Object – Advanced JavaScript Tutorial

The navigator object allows you to grab information about the browser and visitor’s computer. You can grab the browser name, plugins, OS, language, etc.

Properties

Clear your script and add this bit of code.

The navigator object is pretty tricky. Even though the navigator object has been around since Netscape Navigator 2, the properties and methods are supported in various browsers. The above code has properties supported in all browsers. Let’s go over each one.

  1. appName – This property contains the full browser name.
  2. appVersion – This property contains the version of the browser.
  3. onLine – This property returns true if the user is currently connected to the internet. False is returned if they aren’t connected to the internet.
  4. platform – This property contains the system platform the visitor is currently using.
  5. plugins – This property contains an array of plugins installed on the visitor’s current browser.
  6. userAgent – This property contains the user-agent for the  browser.
  7. language – This property contains the language the primary browser is using.
  8. vendor – This property contains the brand name of the browser.
  9. cookieEnabled – This property contains true of false if cookies are enabled in the browser.

There are more properties, but these are supported in all browsers.

Methods

Add this bit of code to your script.

There’s only 1 method that works in all browsers which is the javaEnabled() method. This method will return true if the browser has Java installed. False if it isn’t.

The navigator comes with more methods, but some of those methods are browser specific.

Conclusion

The navigator object can really help you detect the settings and info about the current browser. If you would like more information on the navigator object, then go here.

https://developer.mozilla.org/en-US/docs/Web/API/window.navigator

About Jasko Koyn

Check Also

Try-Catch Statement

Try-catch Statement – Advanced JavaScript Tutorial

The try-catch statement is a unique way to handle errors. When errors occur, usually it …

Leave a Reply

Your email address will not be published. Required fields are marked *

ULTIMATE WORDPRESS DEVELOPMENT COURSE
Want to learn how to create your own custom WordPress plugins and themes? Check out my course!
Get 93% off my course. You'll also learn how to integrate WooCommerce and BuddyPress into your projects. This is a limited time offer
Yes, I would like to get 93% off your course!
No Thanks!
close-link