Availability: |
| ||||||
JavaScript syntax: | - | myWindow.navigator | |||||
- | navigator | ||||||
Object properties: | appCodeName, appMinorVersion, appName, appVersion, browserLanguage, constructor, cookieEnabled, cpuClass, language, onLine, opsProfile, platform, securityPolicy, systemLanguage, userAgent, userLanguage, userProfile | ||||||
Object methods: | javaEnabled(), plugins, preference(), savePreferences(), taintEnabled() | ||||||
Collections: | mimeTypes[], plugins[] |
The navigator object is named after Netscape Navigator but is also present in other browsers since it has become the de facto standard way of enquiring as to a browser's provenance.
You can inspect the various properties belonging to the navigator object and establish the name and type of the browser, its version and the platform it is running on.
The navigator object is available as a property of the window and also the Global object but it will be the same navigator object. There is only one and you cannot instantiate another.
As this object is persistent, you might add properties to it that can be passed from window to window. However this will only work on Netscape, because MSIE seems to initialize a new navigator object for each window. MSIE does allow you to add properties to navigator object but they are private to that window. Netscape shares them across windows. The example shows how to make this work.
You can accomplish the same thing in a cross browser portable manner by using a frameset and storing properties in the top level frameset's Global object. You can also (if security allows) write scripts to communicate between windows, in which case you may need to make sure the scripts are aware of multiple document objects as well as windows. This can get tricky and you may need to make sure the scripts run in the correct windows and return a value to a caller. This should ensure they run in the correct scope.
Netscape 6.0 provides a sidebar which you should expect to be persistent. There's a similar sidebar in MSIE too. Netscape clearly intends you to script its sidebar but right now the implementation is a bit buggy. It might be too much to hope for, but digging into the internals of these suggests that RDF is involved, which may point to some commonality. Maybe we will be able to use the sidebar in the browsers as a repository for session storage, or persistent values that we can access from script, but it's not there and working yet.
You cannot enumerate the properties of the navigator (clientInformation) object in MSIE version 4.5 for Macintosh. This may apply to other platform implementations of MSIE version 4.5 as well.
The navigator object is much better supported in version 5.0 of MSIE for Macintosh, which was released in the Spring of 2000.
The example below was found not to work on Netscape 6, due to bugs.
<!-- Save this in navigator.html --> <HTML> <HEAD></HEAD> <BODY> <SCRIPT> navigator.myNewProperty = "session global value"; open("navigator1.html") </SCRIPT> </BODY> </HTML> --------------------------------------------------------------- <!-- Save this in navigator1.html --> <HTML> <HEAD></HEAD> <BODY> <SCRIPT> document.write(navigator.myNewProperty); </SCRIPT> </BODY> </HTML>
See also: | Cross platform compatibility, Window.navigator |
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
appCodeName | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
appMinorVersion | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
appName | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
appVersion | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
browserLanguage | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
constructor | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
cookieEnabled | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
cpuClass | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
language | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
onLine | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
opsProfile | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
platform | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
securityPolicy | 1.4 ![]() | ![]() | 4.7 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
systemLanguage | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
userAgent | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
userLanguage | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
userProfile | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
javaEnabled() | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
plugins | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
preference() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
savePreferences() | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
taintEnabled() | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
Prev | Home | Next |
navigator | Up | Navigator.appCodeName |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |