spacer

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

home / programming / javascript / diaries / 10

[next]

Subject Matter Expert - Managed Services (TX)
Next Step Systems
US-TX-Dallas

Justtechjobs.com Post A Job | Post A Resume
Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow


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 >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark

Created: October 14, 2005

URL: