NetworkInformation: change イベント
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
change
イベントは、接続情報が変更されたときに発行され、 NetworkInformation
オブジェクトで受信されます。
構文
このイベント名を addEventListener()
等のメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
js
addEventListener("change", (event) => {});
onchange = (event) => {};
イベント型
一般的な Event
です。
例
js
// 接続型の取得
const type = navigator.connection.type;
function changeHandler(e) {
// ここで接続型の変更を操作する
}
// change イベントの登録
navigator.connection.onchange = changeHandler;
// 他の方法: navigator.connection.addEventListener('change', changeHandler);
仕様書
Specification |
---|
Network Information API # dom-networkinformation-onchange |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
change event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.