navigator
Contains information about the version of Navigator in use.
JavaScript 1.1: added
JavaScript 1.2: added |
Created by
The JavaScript runtime engine on the client automatically creates thenavigator object.
Description
Use thenavigator object to determine which version of the Navigator your users have, what MIME types the user's Navigator can handle, and what plug-ins the user has installed. All of the properties of the navigator object are read-only.
Property Summary
| Property |
Description
|
|
|
|
| Indicates the machine type for which the Navigator was compiled.
|
| |
|---|
Method Summary
| Method |
Description
|
| Allows a signed script to get and set certain Navigator preferences.
|
| |
|---|
watch and unwatch methods from Object.
appCodeName
A string specifying the code name of the browser.Examples
The following example displays the value of theappCodeName property:
document.write("The value of navigator.appCodeName is " +For Navigator 2.0 and later, this displays the following:
navigator.appCodeName)
The value of navigator.appCodeName is Mozilla
appName
A string specifying the name of the browser.Examples
The following example displays the value of theappName property:
document.write("The value of navigator.appName is " +For Navigator 2.0 and 3.0, this displays the following:
navigator.appName)
The value of navigator.appName is Netscape
appVersion
A string specifying version information for the Navigator.Description
TheappVersion property specifies version information in the following format:
releaseNumber (platform; country)
The values contained in this format are the following:
-
releaseNumberis the version number of the Navigator. For example,"2.0b4"specifies Navigator 2.0, beta 4. -
platformis the platform upon which the Navigator is running. For example,"Win16"specifies a 16-bit version of Windows such as Windows 3.1. -
countryis either"I"for the international release, or"U"for the domestic U.S. release. The domestic release has a stronger encryption feature than the international release.
Examples
Example 1. The following example displays version information for the Navigator:document.write("The value of navigator.appVersion is " +For Navigator 2.0 on Windows 95, this displays the following:
navigator.appVersion)
The value of navigator.appVersion is 2.0 (Win95, I)For Navigator 3.0 on Windows NT, this displays the following:
The value of navigator.appVersion is 3.0 (WinNT, I)Example 2. The following example populates a
Textarea object with newline characters separating each line. Because the newline character varies from platform to platform, the example tests the appVersion property to determine whether the user is running Windows (appVersion contains "Win" for all versions of Windows). If the user is running Windows, the newline character is set to \r\n; otherwise, it's set to \n, which is the newline character for Unix and Macintosh.
NOTE: This code is needed only for JavaScript 1.0. JavaScript versions 1.1 and later check for all newline characters before setting a string-valued property and translate them as needed for the user's platform.
<SCRIPT>
var newline=null
function populate(textareaObject){
if (navigator.appVersion.lastIndexOf('Win') != -1)
newline="\r\n"
else newline="\n"
textareaObject.value="line 1" + newline + "line 2" + newline
+ "line 3"
}
</SCRIPT>
<FORM NAME="form1">
<BR><TEXTAREA NAME="testLines" ROWS=8 COLS=55></TEXTAREA>
<P><INPUT TYPE="button" VALUE="Populate the Textarea object"
onClick="populate(document.form1.testLines)">
</TEXTAREA>
</FORM>
javaEnabled
Tests whether Java is enabled.Syntax
javaEnabled()
Parameters
None.Description
javaEnabled returns true if Java is enabled; otherwise, false. The user can enable or disable Java by through user preferences.
Examples
The following code executesfunction1 if Java is enabled; otherwise, it executes function2.
if (navigator.javaEnabled()) {
function1()
}
else function2()
See also
navigator.appCodeName, navigator.appName, navigator.userAgent
language
Indicates the translation of the Navigator being used.Description
The value for language is usually a 2-letter code, such as "en" and occasionally a five-character code to indicate a language subtype, such as "zh_CN". Use this property to determine the language of the Navigator client software being used. For example you might want to display translated text for the user.mimeTypes
An array of all MIME types supported by the client.mimeTypes array contains an entry for each MIME type supported by the client (either internally, via helper applications, or by plug-ins). For example, if a client supports three MIME types, these MIME types are reflected as navigator.mimeTypes[0], navigator.mimeTypes[1], and navigator.mimeTypes[2].
Each element of the mimeTypes array is a MimeType object.
To obtain the number of supported mime types, use the length property: navigator.mimeTypes.length.
See also
MimeType
platform
Indicates the machine type for which the Navigator was compiled.Description
Platform values are Win32, Win16, Mac68k, MacPPC and various Unix. The machine type the Navigator was compiled for may differ from the actual machine type due to version differences, emulators, or other reasons. If you use SmartUpdate to download software to a user's machine, you can use this property to ensure that the trigger downloads the appropriate JAR files. The triggering page checks the Navigator version before checking the platform property. For information on using SmartUpdate, see Using JAR Installation Manager for SmartUpdate.plugins
An array of all plug-ins currently installed on the client.Plugin objects installed on the client by using this array. Each element of the plugins array is a Plugin object. For example, if three plug-ins are installed on the client, these plug-ins are reflected as navigator.plugins[0], navigator.plugins[1], and navigator.plugins[2].
To use the plugins array:
1. navigator.plugins[index]
2. navigator.plugins[index][mimeTypeIndex]
index is an integer representing a plug-in installed on the client or a string containing the name of a Plugin object (from the name property). The first form returns the Plugin object stored at the specified location in the plugins array. The second form returns the MimeType object at the specified index in that Plugin object.
To obtain the number of plug-ins installed on the client, use the length property: navigator.plugins.length.
plugins.refresh.
The plugins array has its own method, refresh. This method makes newly installed plug-ins available, updates related arrays such as the plugins array, and optionally reloads open documents that contain plug-ins. You call this method with one of the following statements:
navigator.plugins.refresh(true)If you supply true,
navigator.plugins.refresh(false)
refresh refreshes the plugins array to make newly installed plug-ins available and reloads all open documents that contain embedded objects (EMBED tag). If you supply false, it refreshes the plugins array, but does not reload open documents.
When the user installs a plug-in, that plug-in is not available until refresh is called or the user closes and restarts Navigator.
Examples
The following code refreshes arrays and reloads open documents containing embedded objects:navigator.plugins.refresh(true)See also the examples for the
Plugin object.
preference
Allows a signed script to get and set certain Navigator preferences.Syntax
preference(prefName[, setValue])
Parameters
prefName | |
setValue | The value you want to assign to the preference. This can be a string, number, or Boolean. |
Description
This method returns the value of the preference. If you use the method to set the value, it returns the new value. With permission, you can get and set the preferences shown in the following table.Security
Reading a preference with thepreference method requires the UniversalPreferencesRead privilege. Setting a preference with this method requires the UniversalPreferencesWrite privilege. For information on security, see the Client-Side JavaScript Guide.
See also
savePreferences
savePreferences
Saves the Navigator preferences to the local fileprefs.js.Security
Saving user preferences requires theUniversalPreferencesWrite privilege. For information on security, see the Client-Side JavaScript Guide.
Syntax
SavePreferences()
Description
This method immediately saves the current Navigator preferences to the user'sprefs.js settings file. Navigator also saves preferences automatically when it exits.
See also
preference
taintEnabled
Specifies whether data tainting is enabled.Syntax
navigator.taintEnabled()
Description
Tainting prevents other scripts from passing information that should be secure and private, such as directory structures or user session history. JavaScript cannot pass tainted values on to any server without the end user's permission. UsetaintEnabled to determine if data tainting is enabled. taintEnabled returns true if data tainting is enabled, false otherwise. The user enables or disables data tainting by using the environment variable NS_ENABLE_TAINT.
Examples
The following code executes function1 if data tainting is enabled; otherwise it executes function2.if (navigator.taintEnabled()) {
function1()
}
else function2()
See also
taint, untaint
userAgent
A string representing the value of the user-agent header sent in the HTTP protocol from client to server.Description
Servers use the value sent in the user-agent header to identify the client.Examples
The following example displaysuserAgent information for the Navigator:
document.write("The value of navigator.userAgent is " +For Navigator 2.0, this displays the following:
navigator.userAgent)
The value of navigator.userAgent is Mozilla/2.0 (Win16; I)
Table of Contents | Previous | Next | Index
Last Updated: 05/28/99 11:59:59
