这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
NetworkInformation.onchange
event handler contains the code that is fired when connection information changes, and the
change
is received by the
NetworkInformation
对象。
netInfo.onchange = function() { ... }
// Get the connection type.
var type = navigator.connection.type;
function changeHandler(e) {
// Handle change of connection type here.
}
// Register for event changes:
navigator.connection.onchange = changeHandler;
// Another way: navigator.connection.addEventListener('change', changeHandler);
| 规范 | 状态 | 注释 |
|---|---|---|
|
网络信息 API
The definition of 'onchange' in that specification. |
草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onchange
|
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 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
NetworkInformation
downlink
downlinkMax
onchange
rtt
saveData
type