Navigator
objectSupport in all current engines.
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.
navigator
. appCodeName
Returns the string "Mozilla
".
navigator
. appName
Returns the string "Netscape
".
navigator
. appVersion
Returns the version of the browser.
navigator
. platform
Returns the name of the platform.
navigator
. product
Returns the string "Gecko
".
navigator
. productSub
Returns either the string "20030107
", or the string "20100101
".
navigator
. userAgent
Support in all current engines.
Returns the complete `User-Agent
` header.
navigator
. vendor
Support in all current engines.
Returns either the empty string, the string "Apple Computer, Inc.
",
or the string "Google Inc.
".
navigator
. vendorSub
Returns the empty string.
navigator
. language
Support in all current engines.
Returns a language tag representing the user's preferred language.
navigator
. languages
Support in all current engines.
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.
registerProtocolHandler()
methodNavigator/registerProtocolHandler
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.
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.
navigator
. cookieEnabled
Support in all current engines.
Returns false if setting a cookie will be ignored, and true otherwise.
navigator
. plugins
. refresh
( [ refresh ] )Support in one engine only.
Updates the lists of supported plugins and MIME types for this page, and reloads the page if the lists have changed.
navigator
. plugins
. length
Returns the number of plugins, represented by Plugin
objects, that the user agent reports.
navigator
. plugins
. item
(index)navigator
. plugins
[index]Returns the specified Plugin
object.
navigator
. plugins
. item
(name)navigator
. plugins
[name]Returns the Plugin
object for the plugin with the given name.
navigator
. mimeTypes
. length
Support in one engine only.
Returns the number of MIME types, represented by MimeType
objects, supported by the plugins that the user agent reports.
navigator
. mimeTypes
. item
(index)navigator
. mimeTypes
[index]Returns the specified MimeType
object.
navigator
. mimeTypes
. item
(name)navigator
. mimeTypes
[name]Returns the MimeType
object for the given MIME type.
name
Returns the plugin's name.
description
Returns the plugin's description.
filename
Returns the plugin library's filename, if applicable on the current platform.
length
Returns the number of MIME types, represented by MimeType
objects, supported by the plugin.
item
(index)Returns the specified MimeType
object.
item
(name)Returns the MimeType
object for the given MIME type.
type
Returns the MIME type.
description
Returns the MIME type's description.
suffixes
Returns the MIME type's typical file extensions, in a comma-separated list.
enabledPlugin
Returns the Plugin
object that implements this MIME type.
navigator
. javaEnabled()
Support in one engine only.
Returns true if there's a plugin that supports the MIME type "application/x-java-vm
".