WorkerGlobalScope: offline イベント
offline
は WorkerGlobalScope
のイベントで、端末がインターネットへの接続を失ったときに発行されます。
構文
このイベント名を addEventListener()
などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
js
addEventListener("offline", (event) => {});
onoffline = (event) => {};
イベント型
一般的な Event
です。
例
次のコードでは、ワーカーに onoffline
ハンドラーを設定しています。
js
self.onoffline = () => {
console.log("Your worker is now offline");
};
同じスニペットですが、 addEventListener()
を使用したものです。
js
self.addEventListener("offline", () => {
console.log("Your worker is now offline");
});
仕様書
Specification |
---|
HTML # handler-workerglobalscope-onoffline |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
offline 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.
関連情報
所属先の WorkerGlobalScope
インターフェイス。