XRSession: end event

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

A end event is fired on XRSession interface when the XR session is ended, either by application or User Agent.

It's a XRSessionEvent so it has an additional property session that referencess the XRSession that has ended.

Bubbles No
Cancelable No
Interface XRSessionEvent
Event handler XRSession.onend

Example

You can use the end event in an addEventListener method:

XRSession.addEventListener("end", function(event) {
  console.log("The XR session has ended")
});

Or use the XRSession.onend event handler property:

XRSession.onend = function(event) {
  console.log("The XR session has ended")
}

Specifications

Specification Status Comment
WebXR Device API
The definition of 'end event' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
end eventChrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

No support  
No support