Window.onvrdisplaypresentchange

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

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 compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support 65
Disabled
Full support 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.
Edge ? Firefox Full support 63
Notes
Full support 63
Notes
Notes Only Windows and macOS support is enabled.
Full support 55
Notes
Notes Only Windows support is enabled.
IE No support NoOpera No support NoSafari No support NoWebView Android ? Chrome Android Full support 56
Notes
Full support 56
Notes
Notes Chrome for Android 56 supports only Google Daydream View.
Notes Chrome for Android 57 adds support for Google Cardboard.
Edge Mobile ? Firefox Android Full support 55Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yes
Notes
Full support Yes
Notes
Notes Supported on Samsung Internet for GearVR.

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

文档标签和贡献者

此页面的贡献者: wbamberg, chrisdavidmills, mattwojo
最后编辑者: wbamberg,