orientationchange

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

Bubbles No
Cancelable No
Interface Event
Event handler onorientationchange

示例

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

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

或者使用 onorientationchange 事件处理程序属性:

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

规范

规范 状态
Compatibility Standard
orientationchange
Living Standard

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
orientationchange event
Deprecated
Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 44Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

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