Navigator
Navigator
介面標示了用戶代理(user agent)的狀態與身份。它允許腳本查詢與註冊,以進行一些活動。
Navigator
可以被檢索,只要使用唯讀的 window.navigator
屬性。
屬性
標準
-
Returns an array containing every
VRDisplay
(en-US) object that is currently presenting (VRDisplay.ispresenting
(en-US) istrue
). -
Returns the internal "code" name of the current browser. Do not rely on this property to return the correct value.
-
Returns a
DOMString
with the official name of the browser. Do not rely on this property to return the correct value. -
Returns the version of the browser as a
DOMString
. Do not rely on this property to return the correct value. -
Returns a
BatteryManager
(en-US) object you can use to get information about the battery charging status. -
Provides a
NetworkInformation
(en-US) object containing information about the network connection of a device. -
Returns false if setting a cookie will be ignored and true otherwise.
-
Returns a
Geolocation
object allowing accessing the location of the device. -
Returns the number of logical processor cores available.
-
Returns a
Boolean
(en-US) flag indicating whether the host browser is Java-enabled or not. -
Returns a
DOMString
representing the preferred language of the user, usually the language of the browser UI. Thenull
value is returned when this is unknown. -
Returns an array of
DOMString
representing the languages known to the user, by order of preference. -
Returns an
MimeTypeArray
(en-US) listing the MIME types supported by the browser. -
Returns a
Boolean
(en-US) indicating whether the browser is working online. -
Returns a string that represents the current operating system.
-
Returns a
Permissions
(en-US) object that can be used to query and update permission status of APIs covered by the Permissions API. -
Returns a string representing the platform of the browser. Do not rely on this function to return a significant value.
-
Returns a
PluginArray
(en-US) listing the plugins installed in the browser. -
Always returns
'Gecko'
, on any browser. This property is kept only for compatibility purpose. -
Returns a
ServiceWorkerContainer
(en-US) object, which provides access to registration, removal, upgrade, and communication with theServiceWorker
(en-US) objects for the associated document. -
Returns the singleton
StorageManager
(en-US) object used for managing persistance permissions and estimating available storage on a site-by-site/app-by-app basis. -
Returns the user agent string for the current browser.
Non-standard
備註: Firefox OS devices adds more non-standard properties. You can consult them on the Firefox OS Navigator extensions article.
-
Returns the build identifier of the browser (e.g., "2006090803").
-
Returns a boolean indicating whether cookies are enabled in the browser or not.
-
Returns the
CredentialsContainer
(en-US) interface which exposes methods to request credentials and notify the user agent when interesting events occur such as successful sign in or sign out. -
Reports the value of the user's do-not-track preference. When this value is "yes", your web site or application should not track the user.
-
Returns the
id
object which you can use to add support for BrowserID to your web site. -
Returns a reference to a
MediaDevices
object which can then be used to get information about available media devices (MediaDevices.enumerateDevices()
), find out what constrainable properties are supported for media on the user's computer and user agent (MediaDevices.getSupportedConstraints()
(en-US)), and to request access to media usingMediaDevices.getUserMedia()
(en-US). -
Navigator.mozNotification
已棄用 非標準Navigator.webkitNotification
-
Returns a
notification
object you can use to deliver notifications to the user from your web application. -
The Object, returned by the
navigator.mozSocial
property, is available within the social media provider's panel to provide functionality it may need. -
Returns a reference to the
Presentation
(en-US) API. -
Returns the build number of the current browser (e.g., "20060909").
-
Returns an empty string. In Netscape 4.7x, returns "US & CA domestic policy" or "Export policy".
-
Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.
-
Returns a
StorageQuota
(en-US) interface which provides means to query and request storage usage and quota information. -
Returns the vendor name of the current browser (e.g., "Netscape6").
-
Returns the vendor version number (e.g. "6.1").
-
Returns a PointerLock object for the Mouse Lock API (en-US).
方法
Doesn't inherit any method, but implements those defined in NavigatorID
(en-US), NavigatorContentUtils
, NavigatorUserMedia
, and NavigatorStorageUtils
.
Standard
-
Returns a promise that resolves to an array of
VRDisplay
(en-US) objects representing any available VR devices connected to the computer. -
After having prompted the user for permission, returns the audio or video stream associated to a camera or microphone on the local computer.
-
Allows web sites to register themselves as a possible handler for a given MIME type.
-
Allows web sites to register themselves as a possible handler for a given protocol.
-
Returns a
Promise
for a MediaKeySystemAccess object. -
Used to asynchronously transfer a small amount of data using HTTP from the User Agent to a web server.
-
Invokes the native sharing mechanism of the current platform.
-
Returns
false
. JavaScript taint/untaint functions removed in JavaScript 1.2. -
Causes vibration on devices with support for it. Does nothing if vibration support isn't available.
Non-standard
備註: Firefox OS devices adds more non-standard methods. You can consult them on the Firefox OS Navigator extensions article.
-
Lets code check to see if the document at a given URI is available without using the network.
-
Allows in-app payment.