Navigator:activeVRDisplays 属性

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!

Navigator 接口的只读属性 activeVRDisplays 返回一个包含所有当前正在呈现(VRDisplay.ispresentingtrue)的 VRDisplay 对象的数组。

备注: 此属性是旧版 WebVR API 的一部分。它已被 WebXR 设备 API 取代。

VRDisplay 对象的数组。

示例

js
function showActive() {
  const displays = navigator.activeVRDisplays;
  for (const display of displays) {
    console.log(`显示屏 ${display.displayId} 已激活。`);
  }
}

规范

此属性是旧版 WebVR API 的一部分,已被 WebXR 设备 API 取代。其不再处于标准化轨道。

由于并非所有浏览器都已实现新的 WebXR API,因此建议依赖框架(例如 A-FrameBabylon.jsThree.js)或 polyfill 来开发可在所有浏览器中运行的 WebXR 应用程序 [1]

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
activeVRDisplays
DeprecatedNon-standard
Secure context required
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
User must explicitly enable this feature.
Has more compatibility info.

参见