Navigator
objectinterface Navigator { // objects implementing this interface also implement the interfaces given below }; Navigator implements NavigatorID; Navigator implements NavigatorOnLine; Navigator implements NavigatorContentUtils; Navigator implements NavigatorStorageUtils;
[NoInterfaceObject] interface NavigatorID { readonly attribute DOMString appName; readonly attribute DOMString appVersion; readonly attribute DOMString platform; readonly attribute DOMString userAgent; };
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
.
appName
Returns the name of the browser.
navigator
.
appVersion
Returns the version of the browser.
navigator
.
platform
Returns the name of the platform.
navigator
.
userAgent
Returns the complete User-Agent header.
[NoInterfaceObject] interface NavigatorContentUtils { // content handler registration void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title); void registerContentHandler(DOMString mimeType, DOMString url, DOMString title); DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url); DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url); void unregisterProtocolHandler(DOMString scheme, DOMString url); void unregisterContentHandler(DOMString mimeType, DOMString url); };
The registerProtocolHandler()
method allows Web sites to register themselves as possible handlers
for particular schemes. 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, he is given the
opportunity to use that Web site. Analogously, the registerContentHandler()
method allows Web sites to register themselves as possible handlers
for content in a particular MIME type. For example, the same online
telephone messaging service could register itself as a handler for
text/vcard
files, so that if the user has no native
application capable of handling vCards, his Web browser can instead
suggest he use that site to view contact information stored on
vCards that he opens. [RFC5724]
RFC6350
navigator
. registerProtocolHandler
(scheme,
url, title)navigator
. registerContentHandler
(mimeType,
url, title)Registers a handler for the given scheme or content type, at the given URL, with the given title.
The string "%s
" in the URL is used as a
placeholder for where to put the URL of the content to be
handled.
Throws a SecurityError
exception if the user agent blocks the registration (this might
happen if trying to register as a handler for "http", for
instance).
Throws a SyntaxError
if the "%s
" string is missing in the URL.
In addition to the registration methods, there are also methods for determining if particular handlers have been registered, and for unregistering handlers.
navigator
.
isProtocolHandlerRegistered
(scheme,
url)navigator
.
isContentHandlerRegistered
(mimeType,
url)Returns one of the following strings describing the state of the handler given by the arguments:
new
registered
declined
navigator
.
unregisterProtocolHandler
(scheme,
url)navigator
.
unregisterContentHandler
(mimeType,
url)Unregisters the handler given by the arguments.
[NoInterfaceObject] interface NavigatorStorageUtils { void yieldForStorageUpdates(); };
navigator
.
yieldForStorageUpdates
()If a script uses the
document.cookie
API, or the localStorage
API, the browser will block
other scripts from accessing cookies or storage until the first
script finishes. [WEBSTORAGE]
Calling the
navigator.yieldForStorageUpdates()
method tells the user
agent to unblock any other scripts that may be blocked, even though
the script hasn't returned.
Values of cookies and items in the Storage
objects
of localStorage
attributes
can change after calling this method, whence its name. [WEBSTORAGE]
External
interfaceinterface External { void AddSearchProvider(DOMString engineURL); unsigned long IsSearchProviderInstalled(DOMString engineURL); };
external
.
AddSearchProvider
( url )Adds the search engine described by the OpenSearch description document at url. [OPENSEARCH]
The OpenSearch description document has to be on the same server as the script that calls this method.
external
.
IsSearchProviderInstalled
( url
)Returns a value based on comparing url to the URLs of the results pages of the installed search engines.
The url is compared to the URLs of the results pages of the installed search engines using a prefix match. Only results pages on the same domain as the script that calls this method are checked.
Another way of exposing search engines using
OpenSearch description documents is using a link
element with the search
link type.