Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The change event of the ScreenOrientation interface fires when the orientation of the screen has changed, for example when a user rotates their mobile phone.
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("change", (event) => { })
onchange = (event) => { }
A generic Event.
In the following example, the change callback prints the new screen orientation type and angle.
screen.orientation.addEventListener("change", (event) => {
const type = event.target.type;
const angle = event.target.angle;
console.log(`ScreenOrientation change: ${type}, ${angle} degrees.`);
});
| Specification |
|---|
| Screen Orientation> # dom-screenorientation-onchange> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
change_event |
38 | 79 | 43 | 25 | 16.4 | 38 | 43 | 25 | 16.4 | 3.0 | 38 | 16.4 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/change_event