Screen.unlockOrientation() is a deprecated, non-standard instance method that cleared every orientation lock the page or app had set. Learn the no-argument call, the old vendor prefixes, when it could run (installed apps / fullscreen), and how to migrate to screen.orientation.unlock()—with five examples and try-it labs.
01
Kind
Instance method
02
Returns
Boolean
03
Status
Deprecated · Non-standard
04
Parameters
None
05
Modern path
orientation.unlock()
06
Context
App / fullscreen
Fundamentals
Introduction
After a game locked the screen to landscape, it often needed a way to let the device rotate freely again. Older APIs did that with screen.unlockOrientation().
That approach is obsolete. Modern browsers unlock via the ScreenOrientation object from screen.orientation. This tutorial covers the legacy method so you can read old code and migrate it safely. Pair it with lockOrientation() when you meet both in the same codebase.
JavaScript
// Legacy only — do not use in new apps
// screen.unlockOrientation();
💡
Beginner tip
MDN: the old method only worked for installed Web apps or pages in fullscreen. A normal browser tab usually could not unlock orientation.
Concept
Understanding the Method
MDN: the unlockOrientation() method of the Screen interface removes all the previous screen locks set by the page/app.
Instance method — historically on window.screen.
Deprecated & Non-standard — not in any specification.
Parameters — none.
Return — true unlocked / false could not unlock.
Foundation
📝 Syntax
JavaScript
unlockOrientation()
Parameters
None.
Return value
A boolean: true if the orientation was successfully unlocked, false if it could not be unlocked.
Today
🎯 Prefer ScreenOrientation.unlock()
Legacy
Modern
screen.unlockOrientation()
screen.orientation.unlock()
Returns boolean
Returns undefined (void)
Deprecated / non-standard
Screen Orientation API
Pair with lockOrientation
Pair with orientation.lock()
JavaScript
// Modern idea
if (screen.orientation && typeof screen.orientation.unlock === "function") {
screen.orientation.unlock();
console.log("called orientation.unlock()");
}
Safety
🛡️ Legacy Feature-Detection Pattern
MDN’s examples normalize prefixed names (and sometimes fall through to modern unlock). Use this only when reading old code—not for new apps.
Screen.unlockOrientation() is Deprecated and Non-standard. Prefer screen.orientation.unlock(). 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.unlockOrientation()
Legacy orientation unlock — use ScreenOrientation.unlock() instead.
LegacyAvoid in new apps
Mozilla FirefoxLegacy mozUnlockOrientation era — prefer orientation.unlock()
Avoid
Google ChromeUse ScreenOrientation.unlock() where available
Avoid legacy
Microsoft EdgeLegacy msUnlockOrientation history — prefer modern API
Avoid legacy
Apple SafariDo not rely on screen.unlockOrientation()
Unavailable / Avoid
OperaFollow Chromium Screen Orientation API
Avoid legacy
Internet ExplorermsUnlockOrientation legacy only
Legacy
unlockOrientation()Deprecated
Bottom line: Feature-detect only for migration. Prefer screen.orientation.unlock() in new code; never require orientation APIs for core UX.
Wrap Up
Conclusion
screen.unlockOrientation() was a deprecated, non-standard way to clear orientation locks with a no-argument call. Feature-detect it only when migrating legacy code, and use screen.orientation.unlock() for new work.
It was a deprecated, non-standard method that removed all previous screen locks set by the page or app. Prefer ScreenOrientation.unlock() instead.
MDN marks Screen.unlockOrientation() as Deprecated and Non-standard. It is not Experimental. Do not use it in new code.
Use screen.orientation.unlock() from the Screen Orientation API. That is the modern path MDN recommends.
MDN: only for installed Web apps or for Web pages in fullscreen mode. Ordinary tabs usually could not unlock (or lock) orientation.
true if the orientation was successfully unlocked, false if it could not be unlocked.
Vendors shipped prefixed names (mozUnlockOrientation, msUnlockOrientation). Legacy snippets often feature-detect across those names.
Did you know?
Unlock is the twin of lock. If a legacy game called lockOrientation("landscape") on enter, it usually called unlockOrientation() on exit so the phone could rotate again—today that pair is orientation.lock() / orientation.unlock().