Element: beforexrselect event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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

The beforexrselect event is fired before WebXR select events (select, selectstart, selectend) are dispatched. It can be used to suppress XR world input events while the user is interacting with a DOM overlay UI.

This event bubbles, is cancelable and is composed.

Syntax

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

js
addEventListener("beforexrselect", (event) => { })

onbeforexrselect = (event) => { }

Event type

An XRSessionEvent. Inherits from Event.

Event XRSessionEvent

Event properties

session Read only

The XRSession to which the event refers.

Event availability

The beforexrselect event is a global event and available to the following interfaces:

Examples

To suppress WebXR select events (select, selectstart, selectend), an application can listen for the beforexrselect event. The event bubbles, so a call to preventDefault() on the DOM overlay element will prevent any WebXR select events within this container allowing interaction with the DOM element and avoiding duplicate event input to the XR world.

js
document
  .getElementById("xr-overlay")
  .addEventListener("beforexrselect", (ev) => ev.preventDefault());

Specifications

Specification
WebXR DOM Overlays Module
# onbeforexrselect

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
beforexrselect event
Experimental
Chrome – Full support
Chrome 83 (Release date: 2020-05-19)
footnote Full support
Edge – Full support
Edge 83 (Release date: 2020-05-21)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 69 (Release date: 2020-06-24)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 83 (Release date: 2020-05-19)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 59 (Release date: 2020-06-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 13 (Release date: 2020-12-02)
footnote Full support
WebView Android – No support
WebView Android
footnote
footnote See bug 40652382
WebView on iOS – No support
WebView on iOS
footnote No support

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.
See implementation notes.

See also