screen.lockOrientationUniversal =
screen.lockOrientation ||
screen.mozLockOrientation ||
screen.msLockOrientation;
if (screen.lockOrientationUniversal("landscape-primary")) {
// Orientation was locked
} else {
// Orientation lock failed
}Screen: lockOrientation() method / notebook
Screen: lockOrientation() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
screen.lockOrientationUniversal =
screen.lockOrientation ||
screen.mozLockOrientation ||
screen.msLockOrientation;
if (
screen.lockOrientationUniversal(["landscape-primary", "landscape-secondary"])
) {
// Orientation was locked
} else {
// Orientation lock failed
}