const mql = window.matchMedia("(orientation:landscape)");
mql.addEventListener("change", (event) => {
if (event.matches) {
console.log("Now in landscape orientation");
} else {
console.log("Now in portrait orientation");
}
});MediaQueryList: matches property / notebook
MediaQueryList: matches property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.