USB: disconnect イベント
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
USB
インターフェイスの disconnect
イベントは、ペア設定済みのデバイスが切断された時発火します。
構文
addEventListener()
のようなメソッドでイベント名を使うか、イベントハンドラープロパティを設定します。
js
addEventListener("disconnect", (event) => {});
ondisconnect = (event) => {};
イベント型
USBConnectionEvent
です。Event
を継承します。
イベントプロパティ
例
USB デバイスが切断された時、UI を更新したいかもしれません。
js
navigator.usb.addEventListener("disconnect", (event) => {
// UI から event.device を取り除く
});
別の方法として、USB.ondiscconnect
イベントハンドラープロパティを使用して disconnect
イベント用のハンドラーを設定できます。
js
navigator.usb.ondisconnect = (event) => {
// UI から event.device を取り除く
};
仕様書
Specification |
---|
WebUSB API # disconnect |
WebUSB API # ref-for-dom-usb-ondisconnect |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
disconnect event |
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.
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.