Window: deviceorientationabsolute 事件

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

當絕對裝置方向發生變化時,會觸發 deviceorientationabsolute 事件。

此事件不可取消,也不會冒泡。

語法

在諸如 addEventListener() 之類的方法中使用事件名稱,或設定事件處理程式屬性。

js
addEventListener("deviceorientationabsolute", (event) => { })

ondeviceorientationabsolute = (event) => { }

事件型別

一個 DeviceOrientationEvent。繼承自 Event

Event DeviceOrientationEvent

事件屬性

DeviceOrientationEvent.absolute 只讀

一個布林值,表示裝置是否提供絕對方向資料。

DeviceOrientationEvent.alpha 只讀

一個以度為單位表示的數字,表示裝置繞 z 軸的運動,範圍從 0(包含)到 360(不包含)。

DeviceOrientationEvent.beta 只讀

一個以度為單位表示的數字,表示裝置繞 x 軸的運動,範圍從 -180(包含)到 180(不包含)。這代表了裝置的前後運動。

DeviceOrientationEvent.gamma 只讀

一個以度為單位表示的數字,表示裝置繞 y 軸的運動,範圍從 -90(包含)到 90(不包含)。這代表了裝置的左右運動。

DeviceOrientationEvent.webkitCompassHeading 非標準 只讀

一個數字,表示裝置繞世界座標系 z 軸的運動與北方方向之間的差異,以度為單位,範圍從 0 到 360。

DeviceOrientationEvent.webkitCompassAccuracy 非標準 只讀

指南針的精度,表示為正偏差或負偏差。通常為 10。

規範

規範
裝置方向和運動
# dom-window-ondeviceorientationabsolute

瀏覽器相容性

另見