files/en-us/web/api/window/orientationchange_event/index.md
{{APIRef}}{{Deprecated_Header}}
The orientationchange event is fired when the orientation of the device has changed.
This event is not cancelable and does not bubble.
This event is deprecated. Listen for the {{domxref("ScreenOrientation.change_event", "change")}} event of the {{domxref("ScreenOrientation")}} interface instead.
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
addEventListener("orientationchange", (event) => { })
onorientationchange = (event) => { }
A generic {{domxref("Event")}}.
You can use the orientationchange event in an {{domxref("EventTarget/addEventListener", "addEventListener")}} method:
window.addEventListener("orientationchange", (event) => {
console.log(
`the orientation of the device is now ${event.target.screen.orientation.angle}`,
);
});
Or use the onorientationchange event handler property:
window.onorientationchange = (event) => {
console.log(
`the orientation of the device is now ${event.target.screen.orientation.angle}`,
);
};
{{Specifications}}
{{Compat}}