aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/navigator/index.html
blob: 8660fc5c2d5edba272d4d1a877f491b2c4038c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
title: Navigator
slug: Web/API/Navigator
tags:
  - API
  - DOM4
  - Navigator
  - 接口
translation_of: Web/API/Navigator
---
<p>{{apiref("DOM4")}}</p>

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

<p>可以使用只读的 {{domxref("window.navigator")}} 属性检索navigator对象。</p>

<h2 id="属性">属性</h2>

<p>不从<em>{{domxref("NavigatorID")}}, {{domxref("NavigatorLanguage")}}, {{domxref("NavigatorOnLine")}}, {{domxref("NavigatorGeolocation")}}, {{domxref("NavigatorPlugins")}}, {{domxref("NavigatorUserMedia")}}, </em>和 <em>{{domxref("NetworkInformation")}} </em>中继承任何属性,但是实现了定义在这些对象中的如下属性。</p>

<h3 id="标准属性">标准属性</h3>

<dl>
 <dt>{{domxref("Navigator.activeVRDisplays")}} {{readonlyInline}}{{experimental_inline}}</dt>
 <dd>筛选所有的 {{domxref("VRDisplay")}} 对象,把其中所有{{domxref("VRDisplay.ispresenting")}}属性的值为<code>true</code>的对象以数组的形式返回。 </dd>
 <dt>{{domxref("NavigatorID.appCodeName")}} {{readonlyInline}}{{deprecated_inline}}</dt>
 <dd>返回当前浏览器的内部“开发代号”名称。 不能保证此属性返回的值是正确的。</dd>
 <dt>{{domxref("NavigatorID.appName")}} {{readonlyInline}}{{deprecated_inline}}</dt>
 <dd>以 {{domxref("DOMString")}} 的形式返回浏览器官方名称。 不能保证此属性返回的值是正确的。</dd>
 <dt>{{domxref("NavigatorID.appVersion")}} {{readonlyInline}}{{deprecated_inline}}</dt>
 <dd>{{domxref("DOMString")}} 的形式返回浏览器版本。不能保证此属性返回的值是正确的。</dd>
 <dt>{{domxref("Navigator.battery")}} {{readonlyInline}}{{deprecated_inline}}</dt>
 <dd>返回一个 {{domxref("BatteryManager")}} 对象,你可以用它来获取一些电池充电状态的信息。</dd>
 <dt>{{domxref("Navigator.connection")}} {{readonlyInline}}{{experimental_inline}}</dt>
 <dd>提供一个{{domxref("NetworkInformation")}}对象来获取设备的网络连接信息。</dd>
 <dt>{{domxref("Navigator.cookieEnabled")}} {{readonlyinline}}</dt>
 <dd>当忽略 cookie 时返回 false,否则返回 true</dd>
 <dt>{{domxref("Navigator.geolocation")}} {{readonlyInline}}</dt>
 <dd>返回一个 {{domxref("Geolocation")}} 对象,据之可访问设备的地理位位置信息。</dd>
 <dt>{{domxref("NavigatorConcurrentHardware.hardwareConcurrency")}} {{readOnlyInline}}</dt>
 <dd>返回可用的逻辑处理器核心数。</dd>
 <dt>{{domxref("NavigatorPlugins.javaEnabled")}} {{readonlyInline}}{{experimental_inline}}</dt>
 <dd>返回{{domxref("Boolean")}}表明浏览器是否支持Java。</dd>
 <dt>{{domxref('Navigator.keyboard')}} {{readonlyinline}} {{experimental_inline}}</dt>
 <dd>返回一个{{domxref("Keyboard")}}对象,该对象提供对以下功能的访问:检索键盘布局图和切换从物理键盘捕获按键的功能。</dd>
 <dt>{{domxref("NavigatorLanguage.language")}} {{readonlyInline}}</dt>
 <dd>返回{{domxref("DOMString")}}表示用户的首先语言,通常是浏览器用户界面的语言。当未知的时,返回null。</dd>
 <dt>{{domxref("NavigatorLanguage.languages")}} {{readonlyInline}}</dt>
 <dd> 返回一个表示用户已知语言的{{domxref("DOMString")}}数组,并按优先顺序排列。</dd>
 <dt>{{domxref("NavigatorPlugins.mimeTypes")}} {{readonlyInline}}{{experimental_inline}}</dt>
 <dt>{{domxref("Navigator.locks")}} {{readonlyinline}}{{experimental_inline}}</dt>
 <dd>Returns a {{domxref("LockManager")}} object which provides methods for requesting a new {{domxref('Lock')}} object and querying for an existing {{domxref('Lock')}} object</dd>
 <dt>{{domxref("Navigator.mediaCapabilities")}} {{readonlyinline}}{{experimental_inline}}</dt>
 <dd>Returns a {{domxref("MediaCapabilities")}} object that can expose information about the decoding and encoding capabilities for a given format and output capabilities.</dd>
 <dt>{{domxref("Navigator.maxTouchPoints")}} {{readonlyInline}}</dt>
 <dd>Returns the maximum number of simultaneous touch contact points are supported by the current device.</dd>
 <dd>返回{{domxref("MimeTypeArray")}}数组用于列举浏览器所支持的MIME类型。</dd>
 <dt>{{domxref("NavigatorOnLine.onLine")}} {{readonlyInline}}</dt>
 <dd>返回{{domxref("Boolean")}}来表明浏览器是否联网。</dd>
 <dt>{{domxref("Navigator.oscpu")}}</dt>
 <dd>返回当前操作系统名。</dd>
 <dt>{{domxref("Navigator.permissions")}} {{readonlyinline}}{{experimental_inline}}</dt>
 <dd>返回一个{{domxref("Permissions")}}对象,该对象可用于查询和更新<a href="/en-US/docs/Web/API/Permissions_API">Permissions API</a>涵盖的API的权限状态。</dd>
 <dt>{{domxref("NavigatorID.platform")}} {{readonlyInline}}{{experimental_inline}}</dt>
 <dd>返回浏览器平台名,不确定此值是否有效。</dd>
 <dt>{{domxref("NavigatorPlugins.plugins")}} {{readonlyInline}}{{experimental_inline}}</dt>
 <dd>返回{{domxref("PluginArray")}}数组用于列举出浏览器安装的插件。</dd>
 <dt>{{domxref("NavigatorID.product")}} {{readonlyInline}} {{experimental_inline}}</dt>
 <dd>在任意浏览器下都只返回<code>'Gecko'</code>,此属性只用于兼容的目的。</dd>
 <dt>{{domxref("Navigator.serviceWorker")}} {{readonlyInline}}</dt>
 <dd>返回{{domxref("ServiceWorkerContainer")}} 对象用于提供注册、删除、更新以及为了<a href="https://html.spec.whatwg.org/multipage/browsers.html#concept-document-window">associated document</a>{{domxref("ServiceWorker")}}对象之间的通信。</dd>
 <dt>{{domxref("NavigatorStorage.storage")}} {{readonlyinline}}</dt>
 <dd>Returns the singleton {{domxref('StorageManager')}} object used for managing persistence permissions and estimating available storage on a site-by-site/app-by-app basis.</dd>
 <dt>{{domxref("NavigatorID.userAgent")}} {{readonlyInline}}</dt>
 <dd>返回当前浏览器的用户代理。</dd>
 <dt>{{domxref("Navigator.webdriver")}} {{readonlyInline}} {{experimental_inline}}</dt>
</dl>

<h3 id="Methods" name="Methods">非标准方法</h3>

<dl>
 <dt>{{domxref("window.navigator.buildID", "navigator.buildID")}} {{non-standard_inline}}</dt>
 <dd>返回浏览器识别码。这一方法返回时间戳,例如,在Firefox 64发行版中返回"<code>20181001000000</code>"。.</dd>
 <dt>{{domxref("Navigator.cookieEnabled")}} {{non-standard_inline}}</dt>
 <dd>返回布尔值以表明cookies是否能再浏览器中启用</dd>
 <dt>{{domxref("navigator.doNotTrack")}} {{non-standard_inline}}</dt>
 <dd>报告用户的不追踪参数值,当值为yes,你的网址或应用将不追踪用户</dd>
 <dt>{{domxref("navigator.id")}} {{non-standard_inline}}</dt>
 <dd>返回 {{domxref("window.navigator.id", "id")}} 对象, 你能用 <a href="/en-US/docs/BrowserID" title="BrowserID">BrowserID</a> 添加支持 到你的网址</dd>
 <dt>{{domxref("window.navigator.mozApps", "navigator.mozApps")}} {{non-standard_inline}}</dt>
 <dd>Returns an {{domxref("window.navigator.mozApps", "Apps")}} object you can use to install, manage, and control <a href="/Open_Web_Apps" title="Open Web apps">Open Web apps</a>.</dd>
 <dt>{{domxref("Navigator.mozAudioChannelManager", "navigator.mozAudioChannelManager")}} {{non-standard_inline}}</dt>
 <dd>The <code>navigator.mozAudioChannelManager</code> object provides access to the {{domxref("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.</dd>
 <dt>{{domxref("window.navigator.mozNotification","navigator.mozNotification")}} {{deprecated_inline("22")}} {{non-standard_inline}}<br>
 {{domxref("window.navigator.webkitNotification","navigator.webkitNotification")}}</dt>
 <dd>Returns a {{domxref("navigator.mozNotification", "notification")}} object you can use to deliver notifications to the user from your web application.</dd>
 <dt>{{domxref("navigator.mozSocial")}} {{non-standard_inline}}</dt>
 <dd>The Object, returned by the <code>navigator.mozSocial</code> property, is available within the social media provider's panel to provide functionality it may need.</dd>
 <dt>{{domxref("window.navigator.productSub", "navigator.productSub")}} {{non-standard_inline}}</dt>
 <dd>Returns the build number of the current browser (e.g., "20060909").</dd>
 <dt>{{domxref("window.navigator.securitypolicy", "navigator.securitypolicy")}} {{non-standard_inline}}</dt>
 <dd>Returns an empty string. In Netscape 4.7x, returns "US &amp; CA domestic policy" or "Export policy".</dd>
 <dt>{{domxref("window.navigator.standalone", "navigator.standalone")}} {{non-standard_inline}}</dt>
 <dd>Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.</dd>
 <dt>{{domxref("window.navigator.vendor", "navigator.vendor")}} {{non-standard_inline}}</dt>
 <dd>返回当前浏览器的供应商的名字(例如:“Netscape6”)。</dd>
 <dt>{{domxref("window.navigator.vendorSub", "navigator.vendorSub")}} {{non-standard_inline}}</dt>
 <dd>返回供应商版本号码(例如:“6.1”)。</dd>
 <dt><a href="/en-US/docs/API/Pointer_Lock_API" title="Mouse Lock API"><code>navigator.webkitPointer</code></a> {{non-standard_inline}}</dt>
 <dd>Returns a PointerLock object for the <a href="/en-US/docs/API/Pointer_Lock_API" title="Mouse Lock API">Mouse Lock API</a>.</dd>
</dl>

<h2 id="Methods" name="Methods">方法</h2>

<p><em>Doesn't inherit any method, but implements those defined in {{domxref("NavigatorID")}}, {{domxref("NavigatorContentUtils")}}, <em>{{domxref("NavigatorUserMedia")}}, </em>and {{domxref("NavigatorStorageUtils")}}.</em></p>

<h3 id="标准方法">标准方法</h3>

<dl>
 <dt>{{domxref("Navigator.getVRDisplays()")}} {{deprecated_inline}}</dt>
 <dd>Returns a promise that resolves to an array of {{domxref("VRDisplay")}} objects representing any available VR devices connected to the computer.</dd>
 <dt>{{domxref("NavigatorUserMedia.getUserMedia()")}}{{deprecated_inline}}</dt>
 <dd>After having prompted the user for permission, returns the audio or video stream associated to a camera or microphone on the local computer.</dd>
 <dt>{{domxref("window.navigator.registerContentHandler", "navigator.registerContentHandler")}}</dt>
 <dd>Allows web sites to register themselves as a possible handler for a given MIME type.</dd>
 <dt>{{domxref("navigator.registerProtocolHandler", "navigator.registerProtocolHandler")}}</dt>
 <dd>Allows web sites to register themselves as a possible handler for a given protocol.</dd>
 <dt>{{domxref("Navigator.requestMediaKeySystemAccess()")}} {{experimental_inline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} for a MediaKeySystemAccess object.</dd>
 <dt>{{domxref("Navigator.sendBeacon()")}}{{experimental_inline}}</dt>
 <dd>Used to asynchronously transfer a small amount of data using {{Glossary("HTTP")}} from the User Agent to a web server.</dd>
 <dt>{{domxref("Navigator.share()")}}{{experimental_inline}}</dt>
 <dd>Invokes the native sharing mechanism of the current platform.</dd>
 <dt>{{domxref("NavigatorID.taintEnabled()")}} {{deprecated_inline("1.7.8")}} {{obsolete_inline("9.0")}} {{experimental_inline}}</dt>
 <dd>Returns <code>false</code>. JavaScript taint/untaint functions removed in JavaScript 1.2.</dd>
 <dt>{{domxref("Navigator.vibrate()")}} {{gecko_minversion_inline("11.0")}}</dt>
 <dd>Causes vibration on devices with support for it. Does nothing if vibration support isn't available.</dd>
</dl>

<h3 id="Specification" name="Specification">非标准方法</h3>

<dl>
 <dt>{{domxref("window.navigator.mozIsLocallyAvailable", "navigator.mozIsLocallyAvailable")}} {{non-standard_inline}}</dt>
 <dd>Lets code check to see if the document at a given URI is available without using the network.</dd>
 <dt>{{domxref("window.navigator.mozPay", "navigator.mozPay")}} {{non-standard_inline}}</dt>
 <dd>Allows in-app payment.</dd>
</dl>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', '#the-navigator-object', 'the Navigator object')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div>{{Compat("api.Navigator")}}</div>