SHARE
Facebook X Pinterest WhatsApp

The JavaScript Diaries: Part 10

Written By
thumbnail Lee Underwood
Lee Underwood
Mar 26, 2007

There are four objects that provide information about the environment of the user’s system. They belong to the window object: navigator, screen, history and location. These objects are used to obtain information such as screen size and resolution, color depth of the monitor, limited information on the browser history, and the URL. In addition, information such as the user’s operating system, including the browser type, version and language can also be obtained.

In this installment, we’ll look at objects, their related properties and methods. We’ll delve deeper into them when we use them later in our study.

The navigator Object

This object is used to obtain information about the type of browser being used to access the page. It’s usefulness becomes apparent when the user needs to be directed to a different page or perform certain tasks, depending upon their browser:

Properties
appCodeName
appName
appVersion
cookieEnabled
platform
userAgent

Properties

appCodeName

This property returns the internal name of the browse, but it’s not really useful as it always returns Mozilla in Firefox, Netscape, IE, and Opera browsers.

appName

This property returns the ‘official’ name of the browser. IE returns Microsoft Internet Explorer and Firefox and Netscape both return Netscape. Since Opera users can change their browser’s identity, it may appear as Netscape, Opera, or Microsoft Internet Explorer.

appVersion

This property returns the version number of the browser. However, it’s not necessarily the actual version number, but an internal number. For instance, IE versions 4-6 are all shown as version 4.0 and Netscape 6 returns a version number of 5.0. In my version of Firefox, running browser version 1.07, it returns 5.0. That’s because it’s using the same Mozilla engine as Netscape. In addition, it may also return the operating system and the default language of the browser.

There are better ways of determining the version number. One way is to use object detection. We’ll look at this and other methods later in this series.

This property is used to check if the browser will accept cookies. It could be used as follows:

if (navigator.cookieEnabled) {
  // code for cookie here
}

platform

This property returns the operating platform on the user’s computer. It might look something like “Win32” or “MacPPC.” It doesn’t give the version of the operating system.

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.