The Navigator Object

The Navigator object represents the particular browser and allows script functions to access information about the browser being used to access the document.

The Navigator object provides information about the browser that the user is currently using. All the properties are read-only and can not be dynamically changed. Typically the Navigator object properties are used to determine the users browser and navigate to sections of the site containing browser-specific content.

Note : The examples below are targeted at the Window range of platforms (3.1(1), Windows 95 and Windows NT) - this reference does not support possible cross-platform differences for browsers.

Navigator Properties
The appCodeName property returns the code name of the current browser. For example :


would store the current browsers appCodeName property in the variable vCodeName. The navigator.appCodeName value for both Netscape and Internet Explorer is 'Mozilla'.

The Internet Explorer 4.0 specific appMinorVersion property returns the minor version of the navigator object (the users browser). For example, Internet Explorer 4.0 would return 0, a version of Internet Explorer 4.1 would return 1. This will prove useful for browser-determination scripting for future browser versions.

The appName property returns the name of the current browser. For example :


would store the current browsers appName property in the variable vName. The navigator.appName values for Netscape and Internet Explorer are 'Netscape' and 'Microsoft Internet Explorer' respectively.

The appVersion property returns the version of the current browser. For example :


would store the current browsers appVersion property in the variable vVersion.
The Netscape navigator.appVersion string contains information of the following format :

<version> (<Operating_System>; I)

where <Operating_System> is 'Win16', 'Win95', or 'WinNT'. For example, for Netscape 3.0 on the Windows 95 platform, the navigator.appVersion string would be :

3.0 (Win95; I)

The Internet Explorer navigator.appVersion string contains information of the following format :

<compatible_Netscape_version> (compatible; <version>; <Operating_System>)

Where <compatible_Netscape_version> is 2.0 for Internet Explorer 3.01 (and 3.02) and <Operating_System> is either 'Windows 3.1(1)', 'Windows 95' or 'Windows NT'. For example, for Internet Explorer 3.02 on the Windows 95 platform, the navigator.appVersion string would be :

2.0 (compatible; MSIE 3.02; Windows 95)

The Internet Explorer 4.0 specific browserLanguage returns the ISO code representing the localised language of the users browser. For example, a german Internet Explorer would return 'DE' for the browserLanguage property. (see language property for Netscape determination of the users browser language.)

The Internet Explorer 4.0 specific connectionSpeed property returns a value representing the speed of the users current connection. This proves useful for possible re-direction of users to less multimedia-heavy versions of sites, if their connections aren't enough for the site content.

The Internet Explorer 4.0 specific cookieEnabled property returns a boolean value representing whether or not the user has cookies enabled in the browser.

The Internet Explorer 4.0 specific cpuClass property returns a value representing the class of processor on the users machine. For example 'x86' for 486/Pentium etc. machines, 'Alpha' for Digital machines etc.

The Netscape 4.0 specific language property reflects the current language translation of the Navigator client being used. It returns ISO standard country codes, depending on the version; for example en for English versions, fr for French versions etc. (see browserLanguage property for Internet Explorer determination of the users browser language.)

The mimeTypes property is supported by Internet Explorer 4.0, although it returns no values. It has been added to the Internet Explorer 4.0 object model, to retain compatibility with Netscape browsers. Netscape supports the mimeTypes property of the navigator object as containing an array detailing all the mimeTypes that the users browser can handle, either natively, by helper applications, or by plug-in modules. As an object, it has its own properties, which are :

Details the particular MIME type that is handled by the particular plug-in. For example, the LiveAudio plug-in (as standard with Netscape), handles (amongst others), the MIME-type : audio/x-wav
A description of the particular MIME type. For example, the description of the above LiveAudio handled MIME type is : WAV
This gives a reference to whether the particular MIME type is to be handled by a Plug-in. It details whether the particular plug-in is enabled or not.
This gives the suffixes (file extensions) of the file types of the particular MIME types. For example, the suffix for the above MIME type is wav
This returns the total number of MIME types that Netscape can handle, internally, or via installed plug-ins.

As an example, the following code section checks to see whether the user has a suitable VRML plug-in available and if so, displays a VRML world, giving a notice if the plug-in isn't available :

var vVRMLallowed = navigator.mimeTypes["x-world/x-vrml"]
if (vVRMLallowed)
document.writeln("Click <A HREF='htmlib.wrl'>here</A> to see a " + vVRMLallowed.description)
document.writeln("Too bad, can't show you any virtual worlds.")

NOTE : See how it's possible to reference MIME types in the mimeTypes object by its actual type property. The type and description properties can be used in this way.

The Internet Explorer 4.0 specific onLine property returns a boolean (i.e true or false) value depending on whether the user has chosen to 'Work Offline' - a feature of Internet Explorer 4.0 whereby pages can still be viewed directly from the cache. A value of true shows that the user is currently 'on-line' (or has not chosen the 'Work Offline' option - but may still be disconnected); a value of false indicates that the browser is 'Offline'.

The platform property reflects the machine type that the browser is currently running on. For example, on the WindowsNT platform, navigator.platform returns Win32.

The plugins property is different for both browsers. For more details, see the PlugIns collection.

The Internet Explorer 4.0 specific systemLanguage property returns a value indicating the language of the users system (as opposed to browserLanguage which returns the localised language of the browser). If you're site is authored in multiple languages, interrogating the systemLanguage property would allow re-direction to the appropriate content.

The userAgent property returns a property which is the combination of appCodeName and appVersion properties for the the current browser. For example :


would store the current browsers userAgent property in the variable vuAgent.
Both Netscapes and Internet Explorers navigator.userAgent string is of the format :


So, using the above examples, Netscape 3.0 on the Windows 95 platform returns :

Mozilla/3.0 (Win95; I)

while Internet Explorer 3.02 on the Windows 95 platform returns :

Mozilla/2.0 (compatible; MSIE 3.02; Windows95)

for the navigator.userAgent value.

The Internet Explorer 4.0 specific userLanguage property is synonymous with the browserLanguage property and returns a value representative of the users current language settings.

The Internet Explorer 4.0 specific userProfile property provides a way for determining any of the 'Profile' properties that the user has set in Internet Explorer (View|Internet Options|Content|Personal Information). Specifically, it allows the following methods:

sets an entry in the 'Read Request' queue
clears the current request queue, ready for more addReadRequests to be set
performs the read requests as queued by the addReadRequest method
get values from the users 'Personal Information' store, ready for use later

The syntax for these methods is as follows:

navigator.addReadRequest (attribute [,isRequired], success)
The attribute argument specifies the personal information that the script wishes to obtain from the user. isRequired is reserved for future versions of Internet Explorer 4.0 and is currently ignored and success returns a boolean value - true if the request has been added to the queue, false if it hasn't. See the getAttribute method (below) for details of the possible attributes that can be retrieved from the personal information store.

Clears any requests queued by the addReadRequest method.

navigator.doReadRequest (usageCode [, friendlyName [, domain [, path [, expiration]]]])
The doReadRequest method performs the request for the information asked for in the request queue. For obvious security reasons, no script can access any users personal information settings without them knowing and when the doReadRequest method is used, the user is presented with a dialog, telling them that their information has been requested, also giving them the chance to deny the information to the requesting script. usageCode is any of the following codes, as defined by the Internet Privacy Working group:

Code Meaning
0 Used for system admin.
1 Used for research/development
2 Used for completion/support of a current transaction
3 Used for site customisation
4 Used to improve (i.e. target) advertising on site
5 Used to notify visitors about updates to the site
6 Used for marketing departments to contact site visitors
7 Used for linking other collected information
8 Used by the site for other purposes
9 Disclosed to others for customisation of sites
10 Disclosed to others for marketing purposes
11 Disclosed to others who may contact you for marketing, but will request your permission first
12 Disclosed to others for any purpose

This information is passed to the user in the 'Privacy' section of the request dialog box, giving them an idea of the intended use of the personal information by the script/script author.

var = navigator.getAttribute (attributeName, attributeValue)
The getAttribute method is used after the Request queue has been set up and the doReadRequest method has been called to alert the user that the script function is attempting to retrieve personal information. If the attributeName argument is left blank, then nothing is returned. Setting anything for the attributeValue argument currently causes a scripting error. The various attribute properties that can be requested are of the form and can be any of the following:

vCard.Email vCard.DisplayName
vCard.FirstName vCard.LastName
vCard.MiddleName vCard.Cellular
vCard.Gender vCard.JobTitle
vCard.Pager vCard.Company
vCard.Department vCard.Notes
vCard.Office vCard.Homepage
vCard.Home.StreetAddress vCard.Home.City
vCard.Home.State vCard.Home.Zipcode
vCard.Home.Country vCard.Home.Phone
vCard.Home.Fax vCard.Business.StreetAddress
vCard.Business.City vCard.Business.Phone
vCard.Business.Fax vCard.Business.URL
vCard.Business.State vCard.Business.Country

which all correspond to information contained in the personal information store of Internet Explorer

userProfile example
Clicking the button above the following text fields requests various information from you, which you can allow, or deny, for the usage code (see above) chosen from the code box. If you allow the information, it will the be filled in in the text fields.

Your Name
Your e-mail
Your homepage

To do this, it runs the following script functions:

navigator.userprofile.doreadrequest <usageCode>,"The HTML Reference Library"
name = navigator.userprofile.getattribute("vcard.displayname")
email = navigator.userprofile.getattribute("")

where <usageCode> is the number provided by the list box

Navigator Methods
The javaEnabled method can be used to determine whether the user has Java capabilities enabled in their browser. For example :

if (navigator.javaEnabled()) {
else doSomethingElse()

would execute the doSomeJavathing() code if the user has Java enabled, or do the doSomethingElse() code if Java is disabled.

Note that the taintEnabled method is understood by Internet Explorer, but it always returns a value of 'false' as data tainting isn't supported by Internet Explorer. Data Tainting is the Javascript process of protecting data for sending over networks. It prevents supposedly secure and private information from being sent without the users permission. The taintEnabled method takes a boolean value which can be used to set, or remove Data tainting. For more information on Data Tainting, visit the Javascript documentation at

The Netscape 4.0 specific preference method can be used to set various browser preferences (that would normally be set by the user in the 'Preferences' dialog) through scripting. Obviously, this will require a signed script. For information on signed scripts, see Netscape DevEdge Online

Navigator Events
The Navigator object has no events.