--- title: DeviceOrientationEvent slug: Web/API/DeviceOrientationEvent translation_of: Web/API/DeviceOrientationEvent ---
{{apiref("Device Orientation Events")}}{{SeeCompatTable}}
DeviceOrientationEvent
提供了網頁開發者關於目前瀏覽頁面之裝置的物理旋轉方向資訊。
Warning: Currently, Firefox and Chrome do not handle the coordinates the same way. Take care about this while using them.
window.addEventListener('deviceorientation', function(event) { console.log(event.alpha + ' : ' + event.beta + ' : ' + event.gamma); });
Specification | Status | Comment |
---|---|---|
{{SpecName('Device Orientation')}} | {{Spec2('Device Orientation')}} | Initial specification. |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 7.0 [1] | {{CompatVersionUnknown}} | 6 [2] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | 3.0 | {{CompatVersionUnknown}} [1] | {{CompatVersionUnknown}} | 6 [2] | {{CompatNo}} | {{CompatNo}} | 4.2 | {{CompatVersionUnknown}} [1] |
[1] Before version 50, Chrome provided absolute values instead of relative values for this event. Developers still needing absolute values may use the {{domxref("ondeviceorientationabsolute")}} event.
[2] Firefox 3.6, 4, and 5 supported mozOrientation instead of the standard DeviceOrientationEvent
interface