orientationchange

orientationchange事件在设备的纵横方向改变时触发。

Bubbles No
Cancelable No
Interface Event
Event handler onorientationchange

示例

你可以在addEventListener 方法中使用 orientationchange 事件:

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.