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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
orientationchange event |
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.
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.