Navigator

Navigator 接口表示用户代理的状态和标识。它允许脚本查询它和注册自己进行一些活动。

可以使用只读的 window.navigator 属性检索 navigator 对象。

属性

不从 NavigatorID (en-US)NavigatorLanguage (en-US)NavigatorOnLine (en-US)NavigatorGeolocation (en-US)NavigatorPlugins (en-US)NavigatorUserMediaNetworkInformation 中继承任何属性,但是实现了定义在这些对象中的如下属性。

标准属性

筛选所有的 VRDisplay 对象,把其中所有 VRDisplay.ispresenting (en-US) 属性的值为 true 的对象以数组的形式返回。

返回当前浏览器的内部“开发代号”名称。不能保证此属性返回的值是正确的。

DOMString 的形式返回浏览器官方名称。不能保证此属性返回的值是正确的。

DOMString 的形式返回浏览器版本。不能保证此属性返回的值是正确的。

返回一个 BatteryManager 对象,你可以用它来获取一些电池充电状态的信息。

提供一个 NetworkInformation 对象来获取设备的网络连接信息。

当忽略 Cookie 时返回 false,否则返回 true

返回一个 Geolocation 对象,据之可访问设备的地理位位置信息。

返回可用的逻辑处理器核心数。

返回 Boolean (en-US) 表明浏览器是否支持 Java。

返回一个 Keyboard (en-US) 对象,该对象提供对以下功能的访问:检索键盘布局图和切换从物理键盘捕获按键的功能。

返回 DOMString 表示用户的首先语言,通常是浏览器用户界面的语言。当未知的时,返回 null。

返回一个表示用户已知语言的 DOMString 数组,并按优先顺序排列。

返回 MimeTypeArray (en-US) 数组用于列举浏览器所支持的 MIME 类型。

Returns a LockManager object which provides methods for requesting a new Lock object and querying for an existing Lock object

Returns a MediaCapabilities (en-US) object that can expose information about the decoding and encoding capabilities for a given format and output capabilities.

Returns the maximum number of simultaneous touch contact points are supported by the current device.

返回 Boolean (en-US) 来表明浏览器是否联网。

返回当前操作系统名。

返回一个 Permissions 对象,该对象可用于查询和更新 Permissions API (en-US) 涵盖的 API 的权限状态。

返回浏览器平台名,不确定此值是否有效。

返回 PluginArray (en-US) 数组用于列举出浏览器安装的插件。

在任意浏览器下都只返回 'Gecko',此属性只用于兼容的目的。

返回 ServiceWorkerContainer 对象用于提供注册、删除、更新以及为了 associated documentServiceWorker 对象之间的通信。

Returns the singleton StorageManager object used for managing persistence permissions and estimating available storage on a site-by-site/app-by-app basis.

返回当前浏览器的用户代理。

TBD

非标准方法

返回浏览器识别码。这一方法返回时间戳,例如:在 Firefox 64 发行版中返回 20181001000000

返回布尔值以表明 Cookies 是否能再浏览器中启用

报告用户的不追踪参数值,当值为 yes,你的网址或应用将不追踪用户

返回 id 对象,你能用 BrowserID 添加支持到你的网址。

Returns an Apps object you can use to install, manage, and control Open Web apps.

The navigator.mozAudioChannelManager object provides access to the mozAudioChannelManager interface, which is used to manage your Firefox OS device's audio channels, including setting what channel's volume to affect when the volume buttons are pressed inside a particular app.

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 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.

返回当前浏览器的供应商的名字(例如:“Netscape6”)。

返回供应商版本号码(例如:“6.1”)。

Returns a PointerLock object for the Mouse Lock API.

方法

Doesn't inherit any method, but implements those defined in NavigatorID (en-US), NavigatorContentUtils, NavigatorUserMedia, and NavigatorStorageUtils.

标准方法

Returns a promise that resolves to an array of VRDisplay 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.

规范

Specification
HTML Standard
# the-navigator-object

浏览器兼容性

BCD tables only load in the browser