NetworkInformation
NetworkInformation 提供有关设备正在使用的连接与网络进行通信的信息,并提供了在连接类型更改时通知脚本的事件。NetworkInformation 接口是不能被实例化的,而是通过 Navigator 的 connection 属性进行访问。
备注: 此特性在 Web Worker 中可用
Properties
这些属性接口继承自 EventTarget.
NetworkInformation.type(en-US) 只读-
返回设备正在与网络进行通信的连接类型。它将是以下值之一:
bluetoothcellularethernetnonewifiwimaxotherunknown
NetworkInformation.downlinkMax(en-US) 只读-
返回基础连接技术的最大下载速度(Mbps)。
Event handlers
NetworkInformation.onchange(en-US)-
当连接信息更改并在此对象上触发更改时触发的
change。
Methods
这些属性接口同样继承自 EventTarget.
Specifications
| Specification |
|---|
| Network Information API # networkinformation-interface |
Browser compatibility
BCD tables only load in the browser
See also
- Network Information API
- Online and offline events (en-US)
- The
Navigatorinterface that implements it.