W3cubDocs

/Web APIs

Bluetooth: availabilitychanged event

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The availabilitychanged event fires when the Bluetooth system as a whole becomes available or unavailable to the User Agent.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js

addEventListener("availabilitychanged", (event) => { })

onavailabilitychanged = (event) => { }

Event type

A generic Event.

Examples

To be informed when Bluetooth availability changes, you can add a handler to your Bluetooth instance using addEventListener(), like this:

js

Bluetooth.addEventListener("availabilitychanged", (event) => {
  const availability = event.value;
});

Alternatively, you can use the Bluetooth.onavailabilitychanged event handler property to establish a handler for the availabilitychanged event:

js

Bluetooth.onavailabilitychanged = (event) => {
  const availability = event.value;
};

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
availabilitychanged_event 56 79 No No 43 No No No No No No No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/availabilitychanged_event