这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

NetworkInformation interface provides information about the connection a device is using to communicate with the network and provides a means for scripts to be notified if the connection type changes. The NetworkInformation interfaces cannot be instantiated. It is instead accessed through the connection 特性为 Navigator 接口。

注意: 此特征可用于 Web 工作者 .

特性

此接口还继承其父级的特性, EventTarget .

NetworkInformation.downlink 只读

Returns the effective bandwidth estimate in megabits per second, rounded to the nearest multiple of 25 kilobits per seconds.

NetworkInformation.downlinkMax 只读

Returns the maximum downlink speed, in megabits per second (Mbps), for the underlying connection technology.

NetworkInformation.effectiveType 只读

Returns the effective type of the connection meaning one of 'slow-2g', '2g', '3g', or '4g'. This value is determined using a combination of recently observed round-trip time and downlink values.

NetworkInformation.rtt 只读

Returns the estimated effective round-trip time of the current connection, rounded to the nearest multiple of 25 milliseconds.

NetworkInformation.saveData 只读
返回 true if the user has set a reduced data usage option on the user agent.
NetworkInformation.type 只读
Returns the type of connection a device is using to communicate with the network. It will be one of the following values:
  • bluetooth
  • cellular
  • ethernet
  • none
  • wifi
  • wimax
  • other
  • 未知

事件处理程序

NetworkInformation.onchange
The event that's fired when connection information changes and the change is fired on this object.

方法

此接口还继承其父级的方法, EventTarget .

规范

规范 状态 注释
网络信息 API
The definition of 'NetworkInformation' in that specification.
草案 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
NetworkInformation Chrome 61 Edge 79 Firefox No IE No Opera 48 Safari No WebView Android 50 Chrome Android 38 Firefox Android 31 Opera Android 45 Safari iOS No Samsung Internet Android 3.0
downlink Chrome 61 Edge 79 Firefox No IE No Opera 48 Safari No WebView Android 50 Chrome Android 38 Firefox Android ? Opera Android 45 Safari iOS No Samsung Internet Android 3.0
downlinkMax Chrome 61
61
Only supported in Chrome OS
Edge No Firefox No IE No Opera No Safari No WebView Android 50 Chrome Android 38 Firefox Android No Opera Android 45 Safari iOS No Samsung Internet Android 3.0
effectiveType Chrome 61 Edge 79 Firefox No IE No Opera 48 Safari No WebView Android 50 Chrome Android 38 Firefox Android Yes Opera Android 45 Safari iOS No Samsung Internet Android 3.0
onchange Chrome 61 Edge 79 Firefox No IE No Opera 48 Safari No WebView Android 50 Chrome Android 38 Firefox Android No
不支持 No
On Firefox, the event handler property corresponding to the change event is ontypechange .
Opera Android 45 Safari iOS No Samsung Internet Android 3.0
ontypechange Chrome No Edge No Firefox No IE No Opera ? Safari No WebView Android No Chrome Android No Firefox Android ? Opera Android ? Safari iOS No Samsung Internet Android No
rtt Chrome 61 Edge 79 Firefox No IE No Opera 48 Safari No WebView Android 50 Chrome Android 38 Firefox Android No Opera Android 45 Safari iOS No Samsung Internet Android 3.0
saveData Chrome 65 Edge 79 Firefox No IE No Opera Yes Safari No WebView Android 65 Chrome Android 65 Firefox Android ? Opera Android Yes Safari iOS No Samsung Internet Android 9.0
type Chrome 61
61
Only supported in Chrome OS
Edge No Firefox No IE No Opera No Safari No WebView Android 50 Chrome Android 38 Firefox Android No Opera Android 45 Safari iOS No Samsung Internet Android 3.0
Available in workers Chrome 61 Edge 79 Firefox No IE No Opera 48 Safari No WebView Android 50 Chrome Android 38 Firefox Android 53 Opera Android 45 Safari iOS No Samsung Internet Android 3.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. 网络信息 API
  2. NetworkInformation
  3. 特性
    1. downlink
    2. downlinkMax
    3. onchange
    4. rtt
    5. saveData
    6. type
  4. 继承:
    1. EventTarget
  5. Related pages for Network Information API
    1. Navigator.connection

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1