Screen.lockOrientation() is a deprecated, non-standard instance method that locked the screen into one or more orientations. Learn the string and array argument forms, the old vendor prefixes, when it could run (installed apps / fullscreen), and how to migrate to screen.orientation.lock()—with five examples and try-it labs.
01
Kind
Instance method
02
Returns
Boolean
03
Status
Deprecated · Non-standard
04
Argument
String or string[]
05
Modern path
orientation.lock()
06
Context
App / fullscreen
Fundamentals
Introduction
Games and video players sometimes want the device to stay in landscape. Older APIs tried to do that with screen.lockOrientation("landscape-primary") (or an array of allowed orientations).
That approach is obsolete. Modern browsers expose locking on the ScreenOrientation object from screen.orientation. This tutorial covers the legacy method so you can read old code and migrate it safely.
JavaScript
// Legacy only — do not use in new apps
// screen.lockOrientation("landscape-primary");
💡
Beginner tip
MDN: the old method only worked for installed Web apps or pages in fullscreen. A normal browser tab usually could not lock orientation.
Concept
Understanding the Method
MDN: the lockOrientation() method of the Screen interface locks the screen into a specified orientation.
Instance method — historically on window.screen.
Deprecated & Non-standard — not in any specification.
Argument — one orientation string, or an array of strings.
Screen.lockOrientation() is Deprecated and Non-standard. Prefer screen.orientation.lock(). Logos use the shared browser-image-sprite.png sprite from this project. Do not rely on the legacy method for production.
✓ Deprecated · Non-standard
Screen.lockOrientation()
Legacy orientation lock — use ScreenOrientation.lock() instead.
LegacyAvoid in new apps
Mozilla FirefoxLegacy mozLockOrientation era — prefer orientation.lock()
Avoid
Google ChromeUse ScreenOrientation.lock() where available
Avoid legacy
Microsoft EdgeLegacy msLockOrientation history — prefer modern API
Avoid legacy
Apple SafariDo not rely on screen.lockOrientation()
Unavailable / Avoid
OperaFollow Chromium Screen Orientation API
Avoid legacy
Internet ExplorermsLockOrientation legacy only
Legacy
lockOrientation()Deprecated
Bottom line: Feature-detect only for migration. Prefer screen.orientation.lock() with Promise error handling; never require a successful lock for core UX.
Wrap Up
Conclusion
screen.lockOrientation() was a deprecated, non-standard way to lock screen orientation with a string or array argument. Feature-detect it only when migrating legacy code, and use screen.orientation.lock() for new work—always with a fallback when the lock is denied.
Use screen.lockOrientation() in new production apps
Assume a true return means an instant lock
Require orientation lock for core product flows
Ignore fullscreen / installed-app constraints from MDN
Skip checking MDN’s Deprecated and Non-standard warnings
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about lockOrientation()
Deprecated non-standard orientation lock method.
5
Core concepts
📱01
Method
on Screen
Kind
⚠️02
Deprecated
avoid in new code
Status
🚫03
Non-standard
no public spec
Spec
🔄04
Modern
orientation.lock()
Replace
🎯05
Fallback
locks often fail
UX
❓ Frequently Asked Questions
It was a deprecated, non-standard method that locked the screen into a specified orientation (string or array of strings). 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 modern 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.
Did you know?
Locking orientation without user context would be surprising on a phone. That is why both the old and new APIs are gated (installed app, fullscreen, or similar policies)—and why a denied lock is a normal result, not necessarily a bug in your code.