screen.lockOrientation(orientation) was a legacy way to lock the screen into one or more orientation strings (MDN). Today it is Deprecated and Non-standard — literacy only. Prefer screen.orientation.lock().
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call screen.lockOrientation. Start with this line.
JavaScript
screen.lockOrientation(orientation)
Call
What it does
screen.lockOrientation(orientation)
Primary signature.
screen.lockOrientation(...)
Call with the arguments your case needs.
Built into the browser. Call lockOrientation(...) on a Screen — no import required.
Library declarations
JavaScript
screen.lockOrientation(orientation)
Parameters
Parameter
Description
orientation
Required. String or array of orientation names
Return Value
Return Value
Description
*
boolean — authorized vs denied
JavaScript Examples
Example 1 — Detect Legacy Lock Helpers
Feature-detect unprefixed and vendor-prefixed names (MDN pattern).
JavaScript
const lockOrientationUniversal =
screen.lockOrientation ||
screen.mozLockOrientation ||
screen.msLockOrientation;
if (typeof lockOrientationUniversal === "function") {
console.log("legacy lockOrientation API present");
} else {
console.log("lockOrientation not supported (expected on modern browsers)");
}
Detect screen.orientation.lock — the standard replacement (MDN).
Await the Promise — resolves on success; rejects with DOMExceptions.
Fullscreen often required on mobile browsers before lock succeeds.
Unlock with screen.orientation.unlock() when done.
Compatibility
Browser Support
screen.lockOrientation() is Deprecated and Non-standard. Sparse legacy support (notably Firefox and older Edge / IE). Absent on Chrome and Safari. Prefer screen.orientation.lock() and treat locking as optional.
✓ Deprecated · Non-standard
Screen.lockOrientation()
Legacy orientation lock — boolean return; use ScreenOrientation.lock() instead.
LegacyNot for new code
Google ChromeNo lockOrientation()
No
Microsoft EdgeLegacy Edge / IE era only; Chromium Edge: no
No
Apple SafariNo lockOrientation()
No
OperaNo lockOrientation()
No
Mozilla FirefoxLegacy support (prefixed historically)
It was a non-standard method that locked the screen into a specified orientation (a string or an array of strings). MDN: prefer ScreenOrientation.lock() instead.
MDN marks Screen.lockOrientation() as Deprecated and Non-standard. It is not Experimental. Do not use it in new code.
Use screen.orientation.lock(orientation) from the Screen Orientation API. It returns a Promise and is the path MDN recommends.
MDN: only for installed Web apps or for Web pages in fullscreen mode. Ordinary tabs usually could not lock orientation.
true if locking was authorized, false if denied. MDN notes this does not guarantee the screen is already locked — there may be a delay.
Vendors shipped prefixed names (mozLockOrientation, msLockOrientation). Legacy snippets often feature-detect across those names (MDN).