Packagedom.objects
Classpublic class Navigator
InheritanceNavigator Inheritance Object
Implements NavigatorID, NavigatorOnLine, NavigatorAbilities

Introduced in: DOM 0 
Modified in: HTML 5 

Contains information about the application running the script.

See also

MSDN - navigator Object
MDC - navigator
MDC - window.navigator


Public Properties
 PropertyDefined By
  DOM 0 appCodeName : DOMString
[read-only] Returns the internal "code" name of the current browser.
Navigator
  Non-Standard appMinorVersion : DOMString
[read-only] Retrieves the application's minor version value.
Navigator
  DOM 0 appName : DOMString
[read-only] Returns the official name of the browser.
Navigator
  DOM 0 appVersion : DOMString
[read-only] Returns the version of the browser.
Navigator
  Non-Standard browserLanguage : DOMString
[read-only] Retrieves the current browser language.
Navigator
  Non-Standard buildID : DOMString
[read-only] Returns the build identifier of the browser.
Navigator
  DOM 0 cookieEnabled : Boolean
[read-only] Returns a boolean indicating whether cookies are enabled in the browser or not.
Navigator
  Non-Standard cpuClass : DOMString
[read-only] Retrieves a string denoting the CPU class.
Navigator
  DOM 0 language : DOMString
[read-only] Returns a string representing the language version of the browser.
Navigator
  DOM 0 mimeTypes : MimeTypeArray
[read-only] Returns a MimeTypeArray object, which contains a list of MimeType objects representing the MIME types recognized by the browser.
Navigator
  DOM 0 onLine : Boolean
[read-only] Returns a boolean indicating whether the browser is working online.
Navigator
  DOM 0 oscpu : DOMString
[read-only] Returns a string that represents the current operating system.
Navigator
  DOM 0 platform : DOMString
[read-only] Returns a string representing the platform of the browser.
Navigator
  DOM 0 plugins : PluginArray
[read-only] Returns an PluginArray object, listing the plugins installed in the application.
Navigator
  DOM 0 product : DOMString
[read-only] Returns the product name of the current browser.
Navigator
  DOM 0 productSub : DOMString
[read-only] Returns the build number of the current browser.
Navigator
  Non-Standard securityPolicy : DOMString
[read-only] Returns an empty string.
Navigator
  Non-Standard systemLanguage : DOMString
[read-only] Retrieves the default language used by the operating system.
Navigator
  DOM 0 userAgent : DOMString
[read-only] Returns the user agent string for the current browser.
Navigator
  Non-Standard userLanguage : DOMString
[read-only] Retrieves the operating system's natural language setting.
Navigator
  Non-Standard Obsolete userProfile : UserProfile
[read-only] Provides methods that allow a script to request read access to and perform read actions on a user's profile information.
Navigator
  DOM 0 vendor : DOMString
[read-only] Returns the vendor name of the current browser.
Navigator
  DOM 0 vendorSub : DOMString
[read-only] Returns the vendor version number.
Navigator
Public Methods
 MethodDefined By
  
HTML 5 getStorageUpdates():void
The getStorageUpdates() method, when invoked, must, if the storage mutex is owned by the event loop of the task that resulted in the method being called, release the storage mutex so that it is once again free.
Navigator
  
DOM 0 javaEnabled():Boolean
Indicates whether the host browser is Java-enabled or not.
Navigator
  
Non-Standard mozIsLocallyAvailable(uri:DOMString, ifOffline:Boolean):void
Allows code to determine whether or not a given resource is available.
Navigator
  
Non-Standard preference():Function
Sets a user preference.
Navigator
  
HTML 5 registerContentHandler(mimeType:DOMString, uri:DOMString, title:DOMString):void
Allows web sites to register themselves as possible handlers for content of a particular MIME type.
Navigator
  
HTML 5 registerProtocolHandler(protocol:DOMString, uri:DOMString, title:DOMString):void
Allows web sites to register themselves as possible handlers for particular protocols.
Navigator
  
 Obsolete taintEnabled():Function
Returns whether data tainting is enabled.
Navigator
Property Detail
DOM 0 appCodeNameproperty
appCodeName:DOMString  [read-only]

Introduced in: DOM 0 

Returns the internal "code" name of the current browser.

Note: Mozilla, Netscape 6, and IE5 all use the internal name "Mozilla."


Implementation
    public function get appCodeName():DOMString

See also

appMinorVersionproperty 
appMinorVersion:DOMString  [read-only]

Non-standard (Microsoft)

Retrieves the application's minor version value.


Implementation
    public function get appMinorVersion():DOMString

See also

DOM 0 appNameproperty 
appName:DOMString  [read-only]

Introduced in: DOM 0 
Modified in: HTML 5 

Returns the official name of the browser.


Implementation
    public function get appName():DOMString

See also


Example
         dump(window.navigator.appName);
         // prints "Navigator" to the console for NS6
DOM 0 appVersionproperty 
appVersion:DOMString  [read-only]

Introduced in: DOM 0 
Modified in: HTML 5 

Returns the version of the browser.

Note: The window.navigator.userAgent property also contains the version number (example: "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape 6/6.1"), but you should be aware of how easy it is to change the user agent string and "spoof" other browsers, platforms, or user agents, and also how cavalier the browser vendor themselves are with these properties. The window.navigator.appVersion and window.navigator.userAgent properties are quite often used in "browser sniffing" code: scripts that attempt to find out what kind of browser you are using and adjust pages accordingly.


Implementation
    public function get appVersion():DOMString

See also


Example
         if ( navigator.appVersion.charAt(0) == "5" ) { 
             // browser is putatively a v5 browser
         }
browserLanguageproperty 
browserLanguage:DOMString  [read-only]

Non-standard (Microsoft)

Retrieves the current browser language.

Note (IE): This property does not indicate the language or languages set by the user in Language Preferences, located in the Internet Options dialog box.

Note (IE): In Microsoft Internet Explorer 4.0 and earlier, the browserLanguage property reflects the language of the installed browser's user interface. For example, if you install a Japanese version of Windows Internet Explorer on an English operating system, browserLanguage would be ja.

Note (IE): In Internet Explorer 5 and later, however, the browserLanguage property reflects the language of the operating system regardless of the installed language version of Internet Explorer. However, if Microsoft Windows 2000 MultiLanguage version is installed, the browserLanguage property indicates the language set in the operating system's current menus and dialogs, as found in the Regional Options of the Control Panel. For example, if you install a Japanese version of Internet Explorer 5 on an English (United Kingdom) operating system, browserLanguage would be en-gb. If you install Windows 2000 MultiLanguage version and set the language of the menus and dialogs to French, browserLanguage would be fr, even though you have a Japanese version of Internet Explorer.


Implementation
    public function get browserLanguage():DOMString

See also

buildIDproperty 
buildID:DOMString  [read-only]

Non-standard (Mozilla)

Returns the build identifier of the browser. The build ID is in form YYYYMMDDHH.

Note: Available in Firefox 2 (Gecko 1.8.1) and later.


Implementation
    public function get buildID():DOMString

See also


Example
         dump(window.navigator.buildID); 
         // prints "2006090803" to the console
DOM 0 cookieEnabledproperty 
cookieEnabled:Boolean  [read-only]

Introduced in: DOM 0 

Returns a boolean indicating whether cookies are enabled in the browser or not.

Note (IE): CookieEnabled does not check the status of session cookies.

Note (Mozilla): Due to bug 230350, cookieEnabled may return the wrong result in Gecko-based applications.


Implementation
    public function get cookieEnabled():Boolean

See also


Example
         if (!navigator.cookieEnabled) { 
             // let the user know that enabling cookies makes the web page much more useful
         }
cpuClassproperty 
cpuClass:DOMString  [read-only]

Non-standard (Microsoft)

Retrieves a string denoting the CPU class.

CPU ClassCPU Name
x86Intel processor.
68KMotorola processor.
AlphaDigital processor.
PPCMotorola processor.
OtherOther CPU classes, including Sun SPARC.


Implementation
    public function get cpuClass():DOMString

See also

DOM 0 languageproperty 
language:DOMString  [read-only]

Introduced in: DOM 0 

Returns a string representing the language version of the browser. Examples of valid language codes include "en", "en-US", "fr", "es-ES", etc.

Note: This property also shows up as part of the navigator.userAgent string.


Implementation
    public function get language():DOMString

See also


Example
         if ( window.navigator.language != "en" ) {       
             doLangSelect(window.navigator.language); 
         }
DOM 0 mimeTypesproperty 
mimeTypes:MimeTypeArray  [read-only]

Introduced in: DOM 0 

Returns a MimeTypeArray object, which contains a list of MimeType objects representing the MIME types recognized by the browser.

Note: The zeroth element in mimeTypes (the "Mozilla Default Plug-in" MimeType object) has a type property of instead of a typical MIME format like "image/x-macpaint"


Implementation
    public function get mimeTypes():MimeTypeArray

See also


Example
alert(window.navigator.mimeTypes.item(0).description); // alerts "Mozilla Default Plug-in"
DOM 0 onLineproperty 
onLine:Boolean  [read-only]

Introduced in: DOM 0 
Modified in: HTML 5 

Returns a boolean indicating whether the browser is working online.

Note (IE): In Windows Internet Explorer 8 and later, the onLine property returns true if both of the following conditions are true:

If either of these conditions is false, the onLine property returns false.

Note (IE): In Microsoft Internet Explorer 4.0 through Internet Explorer 7, the onLine property indicates whether the system is in global offline mode. It does not indicate whether the system can communicate with the network.


Implementation
    public function get onLine():Boolean

See also


Example
alert(navigator.onLine ? "You're online" : "You're offline");
DOM 0 oscpuproperty 
oscpu:DOMString  [read-only]

Introduced in: DOM 0 

Returns a string that represents the current operating system.


Implementation
    public function get oscpu():DOMString

See also


Example
         function osInfo() { 
             alert(window.navigator.oscpu); 
         }
         // returns: Windows NT 6.0
DOM 0 platformproperty 
platform:DOMString  [read-only]

Introduced in: DOM 0 
Modified in: HTML 5 

Returns a string representing the platform of the browser.

Platform CodePlatform Name
HP-UXHP UNIX-based computers.
MacPPCMacintosh PowerPC-based computers.
Mac68KMacintosh 68K-based computers.
MacIntelMacintosh Intel-based computers.
Win32Microsoft Windows 32-bit platform.
Win16Windows 16-bit platform.
WinCEWindows CE platform.
Linux i686Linux i686
OtherOther

Note (Mozilla): Unless your code is privileged (chrome or at least has the UniversalBrowserRead privilege), it may get the value of the general.platform.override preference instead of the true platform.


Implementation
    public function get platform():DOMString

See also

DOM 0 pluginsproperty 
plugins:PluginArray  [read-only]

Introduced in: DOM 0 

Returns an PluginArray object, listing the plugins installed in the application. IE: Retrieves a collection of all embed objects within the document.

Note (IE): The collection is an alias for the embeds collection on the document.


Implementation
    public function get plugins():PluginArray

See also


Example
         <script type="text/javascript">
             var L = navigator.plugins.length;
             document.write(L.toString().bold() + " Plugin(s)".bold());
             document.write("<br>");
             document.write("Name | Filename | description".bold());
             document.write("<br>");
             for(var i=0; i<L; i++) {
                 document.write(navigator.plugins[i].name);
                 document.write(" | ");
                 document.write(navigator.plugins[i].filename);
                 document.write(" | ");
                 document.write(navigator.plugins[i].description);
                 document.write("<br>");
             }
         </script>
DOM 0 productproperty 
product:DOMString  [read-only]

Introduced in: DOM 0 

Returns the product name of the current browser.


Implementation
    public function get product():DOMString

See also


Example
         <script>
         function prod() { 
             dt = document.getElementById("d"); 
             dt.innerHTML = window.navigator.product; 
         }
         </script> 
         <button onclick="prod();">product</button> 
         <div id="d"> </div> 
         // returns "Gecko"
DOM 0 productSubproperty 
productSub:DOMString  [read-only]

Introduced in: DOM 0 

Returns the build number of the current browser.

Note: On IE, this property returns undefined.

Note: On Apple Safari this property always returns 20030107.


Implementation
    public function get productSub():DOMString

See also


Example
         <script> 
         function prodsub() {
             dt = document.getElementById("d").childNodes[0];
             dt.data = window.navigator.productSub;
         } 
         </script> 
         <button onclick="prodsub();">productSub</button>
         // returns: 20010725
securityPolicyproperty 
securityPolicy:DOMString  [read-only]

Non-standard (Mozilla)

Returns an empty string. In Netscape 4.7x, returns "US & CA domestic policy" or "Export policy".


Implementation
    public function get securityPolicy():DOMString

See also

systemLanguageproperty 
systemLanguage:DOMString  [read-only]

Non-standard (Microsoft)

Retrieves the default language used by the operating system.


Implementation
    public function get systemLanguage():DOMString

See also

DOM 0 userAgentproperty 
userAgent:DOMString  [read-only]

Introduced in: DOM 0 
Modified in: HTML 5 

Returns the user agent string for the current browser.

Note: Browser identification based on detecting the user agent string is unreliable and is not recommended, as the user agent string is user configurable.


Implementation
    public function get userAgent():DOMString

See also


Example
         alert(window.navigator.userAgent);
         // alerts "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1"
userLanguageproperty 
userLanguage:DOMString  [read-only]

Non-standard (Microsoft)

Retrieves the operating system's natural language setting.

Note (IE): This property reflects the setting in the "Your locale (location)" box in the Regional Options of Control Panel—for example, "English (United States).


Implementation
    public function get userLanguage():DOMString

See also

Non-Standard Obsolete userProfileproperty 
userProfile:UserProfile  [read-only]

Non-standard (Microsoft)

Obsolete

Provides methods that allow a script to request read access to and perform read actions on a user's profile information.

Note (IE): As of Windows Internet Explorer 7, this object is obsolete and should not be used.


Implementation
    public function get userProfile():UserProfile

See also


Example
         // Queue a request for read access to multiple profile attributes.
         navigator.userProfile.addReadRequest("vcard.displayname");
         navigator.userProfile.addReadRequest("vcard.gender");
         
         // Request access to the information.
         navigator.userProfile.doReadRequest(usage-code, "Acme Corporation");
         
         // Now perform read operations to access the information.
         name = navigator.userProfile.getAttribute("vcard.displayname");
         gender = navigator.userProfile.getAttribute("vcard.gender");
         
         // The script can now use the 'name' and 'gender' variables
         // to personalize content or to send information back to the server.
         
         // Clear the request queue to prepare for later information requests.
         navigator.userProfile.clearRequest();
DOM 0 vendorproperty 
vendor:DOMString  [read-only]

Introduced in: DOM 0 

Returns the vendor name of the current browser.


Implementation
    public function get vendor():DOMString

See also


Example
         window.navigator.vendor 
         // returns "Netscape6"
DOM 0 vendorSubproperty 
vendorSub:DOMString  [read-only]

Introduced in: DOM 0 

Returns the vendor version number.


Implementation
    public function get vendorSub():DOMString

See also


Example
         window.navigator.vendorSub 
         // returns "6.1" where the vendor part of userAgent is 
         // Netscape6/6.1
Method Detail
HTML 5 getStorageUpdates()method
public function getStorageUpdates():void

The getStorageUpdates() method, when invoked, must, if the storage mutex is owned by the event loop of the task that resulted in the method being called, release the storage mutex so that it is once again free. Otherwise, it must do nothing.

See also

DOM 0 javaEnabled()method 
public function javaEnabled():Boolean

Introduced in: DOM 0 

Indicates whether the host browser is Java-enabled or not.

Returns
Boolean

See also


Example
         if (window.navigator.javaEnabled()) {
             // browser has java
         }
mozIsLocallyAvailable()method 
public function mozIsLocallyAvailable(uri:DOMString, ifOffline:Boolean):void

Non-standard (Mozilla)

Allows code to determine whether or not a given resource is available.

Note: Security exceptions can occur if the requested URI is not from the same origin.

Parameters

uri:DOMString — URI of the resource whose availability is to be checked, as a string.
 
ifOffline:Boolean — Whether or not the offline resources cache should be checked; specify true to consider the offline resources cache.


Example
         var available = navigator.mozIsLocallyAvailable("my-image-file.png", true);
         if (available) {
             /* the offline resource is present */
         } else {
             alert("Certain needed resources are not available until you connect to the network.");
         }
preference()method 
public function preference():Function

Non-standard (Mozilla)

Sets a user preference. This method is only available to privileged code, and you should use XPCOM Preferences API instead.

Returns
Function

See also

HTML 5 registerContentHandler()method 
public function registerContentHandler(mimeType:DOMString, uri:DOMString, title:DOMString):void

Allows web sites to register themselves as possible handlers for content of a particular MIME type.

Note: For Firefox 2, only the application/vnd.mozilla.maybe.feed, application/atom+xml, and application/rss+xml MIME types are supported. All values have the same effect, and the registered handler will receive feeds in all Atom and RSS versions.

Note: Web sites may only register content handlers for themselves. For security reasons, it's not possible for an extension or web site to register content handlers targeting other sites.

Parameters

mimeType:DOMString — The desired MIME type as a string.
 
uri:DOMString — The URI to the handler as a string.
 
title:DOMString — The title of the handler presented to the user as a string.

See also


Example
         navigator.registerContentHandler("application/vnd.mozilla.maybe.feed",
                                 "http://www.example.tld/?foo=%s",
                                 "My Feed Reader");
HTML 5 registerProtocolHandler()method 
public function registerProtocolHandler(protocol:DOMString, uri:DOMString, title:DOMString):void

Allows web sites to register themselves as possible handlers for particular protocols.

Parameters

protocol:DOMString — The protocol the site wishes to handle, specified as a string.
 
uri:DOMString — The URI to the handler as a string. You can include "%s" to indicate where to insert the escaped URI of the document to be handled.
 
title:DOMString — The title of the handler presented to the user as a string.

See also


Example
If your web application is located at http://www.example.com, you can register a protocol handler for it to handle "mailto" like this:
navigator.registerProtocolHandler("mailto", "http://www.example.com/?uri=%s", "Example Mail");
taintEnabled()method 
public function taintEnabled():Function

Obsolete

Returns whether data tainting is enabled. JavaScript taint/untaint functions removed in JavaScript 1.2[1].

Note (IE): Microsoft Internet Explorer 5 and earlier does not support data tainting and therefore always returns false.

Returns
Function

See also