只读
xr
property provided by the
Navigator
or
WorkerNavigator
interface returns an
XR
object which can be used to access the
WebXR 设备 API
.
const xr = navigator.xr
XR
object used to interface with the
WebXR 设备 API
in the current context. This can be used to present augmented and/or virtual reality imagery to the user.
每个
Window
has its own instance of
Navigator
, which can
be accessed as
Window.navigator
or simply as
navigator
. At the same time, a new
XR
instance is also created and attached to the
navigator
instance as
navigator.xr
。若
xr
property exists and is non-
null
, you can use it to access the
WebXR 设备 API
.
To determine if WebXR is available, you can do something like this:
if ("xr" in Window.navigator) {
/* WebXR can be used! */
} else {
/* WebXR isn't available */
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebXR 设备 API
The definition of 'Navigator.xr' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
xr
|
Chrome 79 | Edge 79 | Firefox No | IE No | Opera No | Safari No | WebView Android No | Chrome Android 79 | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android 11.2 |
完整支持
不支持
实验。期望将来行为有所改变。
Navigator
activeVRDisplays
appCodeName
appName
appVersion
battery
buildID
clipboard
connection
cookieEnabled
credentials
deviceMemory
doNotTrack
geolocation
keyboard
语言
languages
locks
maxTouchPoints
mediaDevices
mediaSession
onLine
oscpu
permissions
platform
product
productSub
serviceWorker
userAgent
vendor
vendorSub
webdriver
xr
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSource
XRInputSourceArray
XRInputSourceEvent
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRRigidTransform
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer