blob: a78634c7ed5a519415fad393a43f2c587188842a (
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
|
---
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>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>20 {{property_prefix("webkit")}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Android Webview</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
<th>Chrome for Android</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatGeckoMobile(31)}} {{property_prefix("moz")}}<sup>[1]</sup></td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatVersionUnknown}}</td>
</tr>
<tr>
<td>Available in workers</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatGeckoMobile(53)}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<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>
|