Detect change in orientation using javascript
NOTE: orientationChange is deprecated Instead use screen.orientation using the screenOrientation interface which is triggered by the screenorientation.onchange event window.addEventListener(“DOMContentLoaded”, () => { const output = document.getElementById(“o9n”); const displayOrientation = () => { const screenOrientation = screen.orientation.type; output.innerHTML = `The orientation of the screen is: ${screenOrientation}`; if (screenOrientation === “landscape-primary”) { console.log(“That looks good.”); } else … Read more