W3cubDocs

/DOM

window.onvrdisplaypresentchange

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

The onvrdisplaypresentchange property of the Window interface represents an event handler that will run when the presenting state of a VR display changes — i.e. goes from presenting to not presenting, or vice versa (when the vrdisplaypresentchange event fires).

The event object is of type VRDisplayEvent.

Syntax

window.onvrdisplaypresentchange = functionRef;

Examples

The presenting state of a VRDisplay can be checked using the VRDisplay.isPresenting property.

window.onvrdisplaypresentchange = function() {
  if(vrDisplay.isPresenting) {
    info.textContent = 'Display has started presenting.';
  } else {
    info.textContent = 'Display has stopped presenting.';
  }
};

Specifications

Specification Status Comment
WebVR 1.1
The definition of 'onvrdisplaypresentchange' in that specification.
Draft Initial definition

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 65
Disabled
65
Disabled
Disabled From version 65: this feature is behind the WebVR preference (needs to be set to Enabled). To change preferences in Chrome, visit chrome://flags.
? 63
63
Only Windows and macOS support is enabled.
55
Only Windows support is enabled.
No No No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support ? 56
56
Chrome for Android 56 supports only Google Daydream View.
Chrome for Android 57 adds support for Google Cardboard.
? 55 No No Yes
Yes
Supported on Samsung Internet for GearVR.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/window/onvrdisplaypresentchange