NetworkInformation

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!
您也可以阅读此文章的English (US)版。

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The NetworkInformation interface provides information about the connection a device is using to commuinicate 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 property of the Navigator interface.

Note: This feature is available in Web Workers.

Properties

This interface also inherits properties of its parent, EventTarget.

NetworkInformation.type Read only
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
  • unknown
NetworkInformation.downlinkMax Read only
Returns the maximum downlink speed, in megabits per second (Mbps), for the underlying connection technology.

Event handlers

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

Methods

This interface also inherits methods of its parent, EventTarget.

Specifications

Specification Status Comment
Network Information API
The definition of 'NetworkInformation' in that specification.
Editor's Draft Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 20 webkit No support No support No support No support
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support (Yes) No support 31.0 (31) moz[1] No support No support No support (Yes)
Available in workers ? No support 53.0 (53) No support No support No support ?

See also

文档标签和贡献者