blob: 23e3aaa29bef61709055724e263f269f372e80ed (
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
|
---
title: Navigator.connection
slug: Web/API/Navigator/connection
translation_of: Web/API/Navigator/connection
---
<div>{{APIRef("Network Information API")}}{{SeeCompatTable}}</div>
<p><code><strong>Navigator.connection</strong></code> 是只读的,提供一个{{domxref("NetworkInformation")}} 对象来获取设备的网络连接信息。例如用户设备的当前带宽或连接是否被计量, 这可以用于基于用户的连接来选择高清晰度内容或低清晰度内容。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"><em>connectionInfo</em> = navigator.connection</pre>
<h3 id="值">值</h3>
<p>返回网络连接状态NetworkInformation对象,包括.downlink(网络下行速度) effectiveType(网络类型) onchange(有值代表网络状态变更) rtt(估算的往返时间) saveData(打开/请求数据保护模式)</p>
<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('Network Information', '#h-the-connection-attribute', 'Navigator.connection')}}</td>
<td>{{Spec2('Network Information')}}</td>
<td>初次定义</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容情况">浏览器兼容情况</h2>
<p>{{Compat("api.Navigator.connection")}}</p>
<h2 id="参考资料">参考资料</h2>
<ul>
<li><a href="/en-US/docs/Online_and_offline_events">Online and offline events</a></li>
</ul>
|