1. 8.9 System state and capabilities
      1. 8.9.1 The Navigator object
        1. Client identification
        2. Language preferences
        3. Browser state
        4. Custom scheme handlers: the registerProtocolHandler() method
        5. Cookies
        6. PDF viewing support

8.9 System state and capabilities

8.9.1 The Navigator object


Support in all current engines.

Edge (Legacy)12+Internet Explorer4+
Firefox Android4+Safari iOS1+Chrome Android18+WebView Android1+Samsung Internet1.0+Opera Android10.1+

Instances of Navigator represent the identity and state of the user agent (the client). They also serve as a generic global under which various APIs are located in this and other specifications. Client identification

In certain cases, despite the best efforts of the entire industry, web browsers have bugs and limitations that web authors are forced to work around.

This section defines a collection of attributes that can be used to determine, from script, the kind of user agent in use, in order to work around these issues.

Client detection should always be limited to detecting known current versions; future versions and unknown versions should always be assumed to be fully compliant.


Returns the string "Mozilla".


Returns the string "Netscape".


Returns the version of the browser.


Returns the name of the platform.


Returns the string "Gecko".


Returns either the string "20030107", or the string "20100101".


Returns the complete `User-Agent` header.


Returns either the empty string, the string "Apple Computer, Inc.", or the string "Google Inc.".


Returns the empty string. Language preferences

Returns a language tag representing the user's preferred language.


Returns an array of language tags representing the user's preferred languages, with the most preferred language first.

The most preferred language is the one returned by navigator.language.

A languagechange event is fired at the Window or WorkerGlobalScope object when the user agent's understanding of what the user's preferred languages are changes.


Returns false if the user agent is definitely offline (disconnected from the network). Returns true if the user agent might be online.

The events online and offline are fired when the value of this attribute changes.

This attribute is inherently unreliable. A computer can be connected to a network without having Internet access.

In this example, an indicator is updated as the browser goes online and offline.

<html lang="en">
  <title>Online status</title>
   function updateIndicator() {
     document.getElementById('indicator').textContent = navigator.onLine ? 'online' : 'offline';
 <body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()">
  <p>The network is: <span id="indicator">(state unknown)</span>
</html> Custom scheme handlers: the registerProtocolHandler() method


Edge (Legacy)NoInternet ExplorerNo
Firefox AndroidNoSafari iOSNoChrome AndroidNoWebView AndroidNoSamsung InternetNoOpera AndroidNo
window.navigator.registerProtocolHandler(scheme, url)

Registers a handler for scheme at url. For example, an online telephone messaging service could register itself as a handler of the sms: scheme, so that if the user clicks on such a link, they are given the opportunity to use that web site. [SMS]

The string "%s" in url is used as a placeholder for where to put the URL of the content to be handled.

Throws a "SecurityError" DOMException if the user agent blocks the registration (this might happen if trying to register as a handler for "http", for instance).

Throws a "SyntaxError" DOMException if the "%s" string is missing in url.

window.navigator.unregisterProtocolHandler(scheme, url)

Unregisters the handler given by the arguments.

Throws a "SecurityError" DOMException if the user agent blocks the deregistration (this might happen if with invalid schemes, for instance).

Throws a "SyntaxError" DOMException if the "%s" string is missing in url. Cookies

Returns false if setting a cookie will be ignored, and true otherwise. PDF viewing support

Returns true if the user agent supports inline viewing of PDF files when navigating to them, or false otherwise. In the latter case, PDF files will be handled by external software.