spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / diaries / 10

[next]

Oracle DBA (IL)
Next Step Systems
US-IL-Lombard

Justtechjobs.com Post A Job | Post A Resume
Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans


The JavaScript Diaries: Part 10

  1. Introduction
  2. Data Types & Variables
  3. Operators
  4. Functions
  5. Conditional Statements and Loops
  6. Objects
  7. Browser-Based Objects
  8. Window Methods
  9. Window Event Handlers
  10. Navigator, Screen, History and Location Objects
  11. Arrays: Part 1 - Introduction
  12. Arrays: Part 2 - Multiple Array Types
  13. Arrays: Part 3 - Array Properties and Methods
  14. The Math Object
  15. The Date Object

By 

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.

cookieEnabled

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.

home / programming / javascript / diaries / 10

[next]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger

Created: October 14, 2005

URL: