Window Management API
The change event of the Screen interface is fired on a specific screen when one or more of the following properties change on it:
- Screen.width
- Screen.height
- Screen.availWidth
- Screen.availHeight
- Screen.colorDepth
- Screen.orientation
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("change", (event) => { })
Alternatively, assign to the event handler property of the interface:
onchange = (event) => { }
Event type
A generic Event.
Examples
const firstScreen = (await window.getScreenDetails()).screens[0];
firstScreen.addEventListener("change", (event) => {
console.log("The first screen has changed.", event, firstScreen);
});
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
