Window: orientationchange event

orientationchange 事件在設備方向改變時被觸發。

冒泡 No
可取消 No
介面 Event
事件處理器 onorientationchange

範例

可於 addEventListener 方法中使用 abort 事件:

js
window.addEventListener("orientationchange", function () {
  console.log(
    "the orientation of the device is now " + screen.orientation.angle,
  );
});

或使用 onorientationchange 事件處理器屬性:

js
window.onorientationchange = function () {
  console.log(
    "the orientation of the device is now " + screen.orientation.angle,
  );
};

規範

Specification
Compatibility
# event-orientationchange

瀏覽器相容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
orientationchange event
Deprecated

Legend

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

Full support
Full support
No support
No support
Deprecated. Not for use in new websites.