NetworkInformation: thuộc tính downlinkMax
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Web Workers.
Thuộc tính chỉ đọc downlinkMax của giao diện NetworkInformation trả về tốc độ tải xuống tối đa, tính bằng megabit mỗi giây (Mbps), của công nghệ kết nối bên dưới.
Giá trị
Một số đại diện cho tốc độ tải xuống tối đa, tính bằng megabit mỗi giây (Mb/s), của công nghệ kết nối bên dưới.
Ví dụ
Ví dụ sau đây giám sát kết nối bằng sự kiện change và ghi lại các thay đổi khi chúng xảy ra.
js
function logConnectionType() {
let connectionType = "not supported";
let downlinkMax = "not supported";
if ("connection" in navigator) {
connectionType = navigator.connection.effectiveType;
if ("downlinkMax" in navigator.connection) {
downlinkMax = navigator.connection.downlinkMax;
}
}
console.log(
`Current connection type: ${connectionType} (downlink max: ${downlinkMax})`,
);
}
logConnectionType();
navigator.connection.addEventListener("change", logConnectionType);
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Network Information API> # dom-networkinformation-downlinkmax> |