DekGenius.com
Team LiB   Previous Section   Next Section
Navigator information about the browser in use

Availability

JavaScript 1.0; enhanced in JavaScript 1.1 and 1.2

Synopsis

navigator 

Properties

appCodeName

A read-only string that specifies the code name of the browser. In all Netscape browsers, this is "Mozilla". For compatibility, this property is "Mozilla" in Microsoft browsers as well.

appName

A read-only string property that specifies the name of the browser. For Netscape, the value of this property is "Netscape". In IE, the value of this property is "Microsoft Internet Explorer".

appVersion

A read-only string that specifies version and platform information for the browser. The first part of this string is a version number. Pass the string to parseInt( ) to obtain only the major version number or to parseFloat( ) to obtain the major and minor version numbers as a floating-point value. The remainder of the string value of this property provides other details about the browser version, including the operating system it is running on. Unfortunately, however, the format of this information varies widely from browser to browser.

cookieEnabled[IE 4, Netscape6]

A read-only boolean that is true if the browser has cookies enabled and false if they are disabled.

language [Netscape 4]

A read-only string that specifies the default language of the browser version. The value of this property is either a standard two-letter language code, such as "en" for English or "fr" for French, or a five-letter string that indicates a language and a regional variant, such as "fr_CA" for French, as spoken in Canada. Note that IE 4 provides two different language-related properties.

mimeTypes[] [Netscape 3]

An array of MimeType objects, each of which represents one of the MIME types (e.g., "text/html" and "image/gif") supported by the browser. The mimeTypes[] array is defined by IE 4 but is always empty because IE 4 does not support the MimeType object.

platform [ JavaScript 1.2]

A read-only string that specifies the operating system and/or hardware platform on which the browser is running. Although there is no standard set of values for this property, some typical values are "Win32", "MacPPC", and "Linux i586".

plugins[] [Netscape 3]

An array of Plugin objects, each of which represents one plugin that was installed with the browser. The Plugin object provides information about the plugin, including a list of MIME types it supports. A plugin is the Netscape name for a software package that is invoked by the browser to display specific data types within the browser window.

The plugins[] array is defined by IE 4 but is always empty because IE 4 does not support plugins or the Plugin object.

systemLanguage [IE 4]

A read-only string that specifies the default language of the operating system using the same standard codes used by the Netscape-specific language property.

userAgent

A read-only string that specifies the value the browser uses for the user-agent header in HTTP requests. Typically, this is the value of navigator.appCodeName followed by a slash and the value of navigator.appVersion. For example:

Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
userLanguage [IE 4]

A read-only string that specifies the user's preferred language using the same standard codes used by the Netscape-specific language property.

Functions

navigator.javaEnabled( )

Tests whether Java is supported and enabled in the current browser. Added in JavaScript 1.1.

navigator.plugins.refresh( )

Checks for newly installed plugins, enters them in the plugins[] array, and optionally reloads documents using those plugins. Added in Netscape 3.

Description

The Navigator object contains properties that describe the web browser in use. You can use its properties to perform platform-specific customization. The name of this object obviously refers to the Netscape Navigator browser, but other browsers that implement JavaScript support this object as well.

There is only a single instance of the Navigator object, which you can reference through the navigator property of any Window object. Because of the implicit window reference, you can always refer to the Navigator object simply as navigator.

See Also

MimeType, Plugin

    Team LiB   Previous Section   Next Section