| Package | dom.objects |
| Class | public class Navigator |
| Inheritance | Navigator Object |
| Implements | NavigatorID, NavigatorOnLine, NavigatorAbilities |
| Introduced in: | DOM 0 |
| Modified in: | HTML 5 |
See also
| Property | Defined 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 | ||
| Method | Defined 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 | ||
Allows code to determine whether or not a given resource is available. | Navigator | ||
Non-Standard preference():Function
Sets a user preference. | Navigator | ||
Allows web sites to register themselves as possible handlers for content of a particular MIME type. | Navigator | ||
Allows web sites to register themselves as possible handlers for particular protocols. | Navigator | ||
Obsolete taintEnabled():Function
Returns whether data tainting is enabled. | Navigator | ||
| DOM 0 appCodeName | property |
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."
public function get appCodeName():DOMStringSee also
| appMinorVersion | property |
appMinorVersion:DOMString [read-only] Non-standard (Microsoft)
Retrieves the application's minor version value.
public function get appMinorVersion():DOMStringSee also
| DOM 0 appName | property |
appName:DOMString [read-only] | Introduced in: | DOM 0 |
| Modified in: | HTML 5 |
Returns the official name of the browser.
public function get appName():DOMStringSee also
dump(window.navigator.appName);
// prints "Navigator" to the console for NS6| DOM 0 appVersion | property |
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.
public function get appVersion():DOMStringSee also
if ( navigator.appVersion.charAt(0) == "5" ) {
// browser is putatively a v5 browser
}| browserLanguage | property |
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.
public function get browserLanguage():DOMStringSee also
| buildID | property |
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.
public function get buildID():DOMStringSee also
dump(window.navigator.buildID);
// prints "2006090803" to the console| DOM 0 cookieEnabled | property |
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.
public function get cookieEnabled():BooleanSee also
if (!navigator.cookieEnabled) {
// let the user know that enabling cookies makes the web page much more useful
}| cpuClass | property |
cpuClass:DOMString [read-only] Non-standard (Microsoft)
Retrieves a string denoting the CPU class.
| CPU Class | CPU Name |
|---|---|
| x86 | Intel processor. |
| 68K | Motorola processor. |
| Alpha | Digital processor. |
| PPC | Motorola processor. |
| Other | Other CPU classes, including Sun SPARC. |
public function get cpuClass():DOMStringSee also
| DOM 0 language | property |
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.
public function get language():DOMStringSee also
if ( window.navigator.language != "en" ) {
doLangSelect(window.navigator.language);
}| DOM 0 mimeTypes | property |
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"
public function get mimeTypes():MimeTypeArraySee also
alert(window.navigator.mimeTypes.item(0).description); // alerts "Mozilla Default Plug-in"
| DOM 0 onLine | property |
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:
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.
public function get onLine():BooleanSee also
alert(navigator.onLine ? "You're online" : "You're offline");
| DOM 0 oscpu | property |
oscpu:DOMString [read-only] | Introduced in: | DOM 0 |
Returns a string that represents the current operating system.
public function get oscpu():DOMStringSee also
function osInfo() {
alert(window.navigator.oscpu);
}
// returns: Windows NT 6.0| DOM 0 platform | property |
platform:DOMString [read-only] | Introduced in: | DOM 0 |
| Modified in: | HTML 5 |
Returns a string representing the platform of the browser.
| Platform Code | Platform Name |
|---|---|
| HP-UX | HP UNIX-based computers. |
| MacPPC | Macintosh PowerPC-based computers. |
| Mac68K | Macintosh 68K-based computers. |
| MacIntel | Macintosh Intel-based computers. |
| Win32 | Microsoft Windows 32-bit platform. |
| Win16 | Windows 16-bit platform. |
| WinCE | Windows CE platform. |
| Linux i686 | Linux i686 |
| Other | Other |
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.
public function get platform():DOMStringSee also
| DOM 0 plugins | property |
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.
public function get plugins():PluginArraySee also
<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 product | property |
product:DOMString [read-only] | Introduced in: | DOM 0 |
Returns the product name of the current browser.
public function get product():DOMStringSee also
<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 productSub | property |
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.
public function get productSub():DOMStringSee also
<script>
function prodsub() {
dt = document.getElementById("d").childNodes[0];
dt.data = window.navigator.productSub;
}
</script>
<button onclick="prodsub();">productSub</button>
// returns: 20010725| securityPolicy | property |
securityPolicy:DOMString [read-only] Non-standard (Mozilla)
Returns an empty string. In Netscape 4.7x, returns "US & CA domestic policy" or "Export policy".
public function get securityPolicy():DOMStringSee also
| systemLanguage | property |
systemLanguage:DOMString [read-only] Non-standard (Microsoft)
Retrieves the default language used by the operating system.
public function get systemLanguage():DOMStringSee also
| DOM 0 userAgent | property |
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.
public function get userAgent():DOMStringSee also
alert(window.navigator.userAgent);
// alerts "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1"| userLanguage | property |
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).
public function get userLanguage():DOMStringSee also
| Non-Standard Obsolete userProfile | property |
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.
public function get userProfile():UserProfileSee also
// 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 vendor | property |
vendor:DOMString [read-only] | Introduced in: | DOM 0 |
Returns the vendor name of the current browser.
public function get vendor():DOMStringSee also
window.navigator.vendor
// returns "Netscape6"| DOM 0 vendorSub | property |
vendorSub:DOMString [read-only] | Introduced in: | DOM 0 |
Returns the vendor version number.
public function get vendorSub():DOMStringSee also
window.navigator.vendorSub
// returns "6.1" where the vendor part of userAgent is
// Netscape6/6.1| HTML 5 getStorageUpdates | () | method |
public function getStorageUpdates():voidThe 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.
ReturnsBoolean |
See also
if (window.navigator.javaEnabled()) {
// browser has java
}| mozIsLocallyAvailable | () | method |
public function mozIsLocallyAvailable(uri:DOMString, ifOffline:Boolean):voidNon-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.
|
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():FunctionNon-standard (Mozilla)
Sets a user preference. This method is only available to privileged code, and you should use XPCOM Preferences API instead.
ReturnsFunction |
See also
| HTML 5 registerContentHandler | () | method |
public function registerContentHandler(mimeType:DOMString, uri:DOMString, title:DOMString):voidAllows 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
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):voidAllows 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
navigator.registerProtocolHandler("mailto", "http://www.example.com/?uri=%s", "Example Mail");| taintEnabled | () | method |
public function taintEnabled():FunctionObsolete
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.
ReturnsFunction |
See also