非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

DeviceOrientationEvent 构造函数创建新 DeviceOrientationEvent .

句法

var deviceOrientationEvent = new DeviceOrientationEvent(type[, options])
					

参数

type

要么 "deviceorientation" or "deviceorientationabsolute" . If the later, then options.absolute should be true.
选项 可选
Options are as follows:
  • alpha : A number representing the motion of the device around the z axis, express in degrees with values ranging from 0 to 360.
  • beta : A number representing the motion of the device around the x axis, express in degrees with values ranging from -180 to 180. This represents a front to back motion of the device.
  • gamma : A number representing the motion of the device around the y axis, express in degrees with values ranging from -90 to 90. This represents a left to right motion of the device.
  • absolute : A boolean that indicates whether or not the device is providing orientation data absolutely.

规范

规范 状态 注释
DeviceOrientation Event Specification 编者草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DeviceOrientationEvent() 构造函数 非标 Chrome 59 Edge ≤79 Firefox ? IE 不支持 No Opera ? Safari ? WebView Android 59 Chrome Android 59 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 7.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

非标。预期跨浏览器支持较差。

元数据

  • 最后修改:
  1. DeviceOrientationEvent
  2. 构造函数
    1. DeviceOrientationEvent()
  3. 特性
    1. absolute
    2. alpha
    3. beta
    4. gamma
  4. 继承:
    1. 事件
  5. Related pages for Device Orientation Events
    1. DeviceAcceleration
    2. DeviceMotionEvent
    3. DeviceRotationRate