The Navigator
object represents the particular browser and allows script functions to access information about the browser being used to access the document.
Properties | Methods | Events |
appCodename, appName, appVersion, userAgent, mimeTypes*, plugins* | javaEnabled* | None |
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.
Navigator Properties
appCodeName
The appCodeName
property returns the code name of the current browser. For example :
vCodeName=navigator.appCodeName
would store the current browsers appCodeName
property in the variable vCodeName
. See below for a table containing the relevant property values for Internet Explorer and Netscape
appName
The appName
property returns the name of the current browser. For example :
vName=navigator.appName
would store the current browsers appName
property in the variable vName
. See below for a table containing the relevant property values for Internet Explorer and Netscape
appVersion
The appVersion
property returns the version of the current browser. For example :
vVersion=navigator.appVersion
would store the current browsers appVersion
property in the variable vVersion
. See below for a table containing the relevant property values for Internet Explorer and Netscape
userAgent
The userAgent
property returns a property which is the combination of appCodeName
and appVersion
properties for the the current browser. For example :
vuAgent=navigator.userAgent
would store the current browsers userAgent
property in the variable vuAgent
. See below for a table containing the relevant property values for Internet Explorer and Netscape
Internet Explorer | Netscape | |
appCodeName | Mozilla | Mozilla |
appName | Microsoft Internet Explorer | Netscape |
appVersion | 2.0 (compatible; MSIE 3.01;Windows 95) | 3.01b1 (Win 95;l) |
userAgent | Mozilla/2.0 (compatible; MSIE 3.01;Windows 95) | Mozilla/3.01b1 (Win 95;l) |
mimeTypes
The Netscape specific mimeTypes
property of the navigator object is actually an object in it's own right. It can be considered part of Netscape's LiveConnect technology (which will be merged with Sun's Java Beans technology) to allow interaction with plug-ins (and eventually Java applets). The mimeTypes
object contains 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 it's own properties, which are :
audio/x-wav
WAV
wav
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)
else
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 it's actual type property. The type and description properties can be used in this way.
plugins
Like the above mimeTypes
object, the plugins
object is also Netscape specific. It is an array of all the currently installed plug-ins available to the navigator
object. As above, the plugins
object contains it's own properties, which can be used to determine suitable content to present to the user. The properties of the plugins object are :
audio/wav
MIME type is named LiveAudio
As an example, the following code section checks to see whether the user has the Live3D plug-in available and if so, displays a VRML world, giving a notice if the plug-in isn't available :
var vVRMLallowed = navigator.plugins["Live3D Plugin DLL"]
if (vVRMLallowed)
document.writeln("Click <A HREF='htmlib.wrl'>here</A> to see a Virtual world"
else
document.writeln("Too bad, can't show you any virtual worlds.")
NOTE : As in the above example, it is possible to reference plugins by their name property.
Navigator Methods
javaEnabled
The Netscape specific javaEnabled
method can be used to determine whether the user has Java capabilities enabled in their browser. (Users can allow/disallow Java capabilities via a setting in the Options|Network Preferences|Languages dialog of Netscae. For example :
if (navigator.javaEnabled()) {
doSomeJavathing()
}
else doSomethingElse()
Navigator Events
The Navigator object has no events.