blob: 2d4cfeb785b05214127a635f59d25a95b8d062fe (
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
|
---
title: NetworkInformation
slug: Web/API/NetworkInformation
translation_of: Web/API/NetworkInformation
---
<div>{{APIRef("Network Information API")}}{{SeeCompatTable}}</div>
<p><code><strong>NetworkInformation</strong></code> 提供有关设备正在使用的连接与网络进行通信的信息,并提供了在连接类型更改时通知脚本的事件。<code>NetworkInformation</code> 接口不能被是实例化, 而是通过 {{domxref("Navigator")}} 的 <code>connection</code> 属性进行访问。</p>
<p>{{AvailableInWorkers}}</p>
<h2 id="Properties">Properties</h2>
<p><em>这些属性接口继承自 {{domxref("EventTarget")}}.</em></p>
<dl>
<dt>{{domxref("NetworkInformation.type")}} {{readonlyinline}}</dt>
<dd>返回设备正在与网络进行通信的连接类型。 它将是以下值之一:
<ul>
<li><code>bluetooth</code></li>
<li><code>cellular</code></li>
<li><code>ethernet</code></li>
<li><code>none</code></li>
<li><code>wifi</code></li>
<li><code>wimax</code></li>
<li><code>other</code></li>
<li><code>unknown</code></li>
</ul>
</dd>
<dt>{{domxref("NetworkInformation.downlinkMax")}} {{readonlyinline}}</dt>
<dd>返回基础连接技术的最大下载速度(Mbps)。</dd>
</dl>
<h3 id="Event_handlers">Event handlers</h3>
<dl>
<dt>{{domxref("NetworkInformation.onchange")}}</dt>
<dd>当连接信息更改并在此对象上触发更改时触发的 {{event("change")}} 。</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>这些属性接口同样继承自 {{domxref("EventTarget")}}.</em></p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('Network Information', '#idl-def-NetworkInformation', 'NetworkInformation')}}</td>
<td>{{Spec2('Network Information')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
{{Compat("api.NetworkInformation")}}
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/en-US/docs/Web/API/Network_Information_API">Network Information API</a></li>
<li><a href="/en-US/docs/Online_and_offline_events">Online and offline events</a></li>
<li>The {{domxref("Navigator")}} interface that implements it.</li>
</ul>
|