Back to Content

XRSessionEvent: XRSessionEvent() constructor

files/en-us/web/api/xrsessionevent/xrsessionevent/index.md

latest1.1 KB
Original Source

{{APIRef("WebXR Device API")}}{{SecureContext_Header}}

The WebXR Device API's XRSessionEvent() constructor creates and returns a new {{domxref("XRSessionEvent")}} object. These objects represent events announcing state changes in an {{domxref("XRSession")}} representing an augmented or virtual reality session.

Syntax

js-nolint
new XRSessionEvent(type, options)

Parameters

  • type
    • : A string with the name of the event. It is case-sensitive and browsers set it to end or visibilitychange.
  • options
    • : An object that, in addition of the properties defined in {{domxref("Event/Event", "Event()")}}, can have the following properties:
      • session
        • : The {{domxref("XRSession")}} to which the event is to be delivered.

Return value

A new {{domxref("XRSessionEvent")}} object representing an object of the specified type and configured as described by the options parameter.

Examples

See XRSessionEvent for example code.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}