NetworkInformation:downlinkMax 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

备注: 此特性在 Web Worker 中可用。

NetworkInformation 接口的 downlinkMax 只读属性返回底层连接技术的最大下行链路速度,以兆比特每秒(Mbps)为单位。

一个代表底层连接技术的最大下行链路速度的数值,单位为兆比特每秒(Mb/s)。

示例

以下示例使用 change 事件监视网络连接并记录发生的更改。

js
function logConnectionType() {
  let connectionType = "不支持";
  let downlinkMax = "不支持";

  if ("connection" in navigator) {
    connectionType = navigator.connection.effectiveType;

    if ("downlinkMax" in navigator.connection) {
      downlinkMax = navigator.connection.downlinkMax;
    }
  }

  console.log(
    `当前连接类型:${connectionType}(下行链路最大值:${downlinkMax}`,
  );
}

logConnectionType();
navigator.connection.addEventListener("change", logConnectionType);

规范

Specification
Network Information API
# dom-networkinformation-downlinkmax

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
downlinkMax
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.