Screen Orientation & Lock

The Screen Orientation API allows web applications to get the information about the current orientation of the document (portrait or landscape) as well as to lock the screen orientation in a requested state.

The current version of the specification defines this feature fully within window.screen.orientation object. The previous version, still available in Microsoft Edge as of June 2017, separated the orientation lock to window.screen.lockOrientation.

API glimpse

Returns the current screen orientation type as one of portrait-primary, portrait-secondary (upside down), landscape-primary and landscape-secondary (upside down).
window.screen.orientation.addEventListener('change', listener)
An event fired when the document orientation has changed.
Requests a screen lock in the lockType specified. Returns a Promise resolved when the lock was acquired successfully.
Removes previously acquired screen orientation lock.