dom / latest / bluetooth / availabilitychanged_event.html /

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.

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:

Bluetooth.addEventListener("availabilitychanged", function(event) {
  var availability = event.value;
});

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

Bluetooth.onavailabilitychanged = function(event) {
 var 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
56
No
43
No
6.0

See also

© 2005–2021 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