ScreenOrientation: unlock() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The unlock() method of the ScreenOrientation interface unlocks the orientation of the containing document, effectively locking it to the default screen orientation.

Syntax

js
unlock()

Parameters

None.

Return value

None (undefined).

Exceptions

InvalidStateError DOMException

Thrown if the document is not fully active.

SecurityError DOMException

Thrown if the document's visibility state is hidden or if the document is forbidden to use the feature (for example, by omitting the keyword allow-orientation-lock of the sandbox attribute of the iframe element).

Specifications

Specification
Screen Orientation
# dom-screenorientation-unlock

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
unlock
Chrome – Partial support
Chrome 38 (Release date: 2014-10-07)
footnote Partial support
footnote Always throws NotSupportedError.
Edge – Partial support
Edge 79 (Release date: 2020-01-15)
footnote Partial support
footnote Always throws NotSupportedError.
Firefox – Partial support
Firefox 43 – 143 (Release date: 2015-12-15)
footnote Partial support
footnote Always throws NotSupportedError.
Firefox – Full support
Firefox 144 (Release date: 2025-10-14)
footnote Full support
Opera – Partial support
Opera 25 (Release date: 2014-10-15)
footnote Partial support
footnote Always throws NotSupportedError.
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 38 (Release date: 2014-10-08)
footnote Full support
Firefox for Android – No support
Firefox for Android 43 – 68 (Release date: 2015-12-15)
unknown Support unknown
Firefox for Android – Partial support
Firefox for Android 79 – 143 (Release date: 2020-07-28)
footnote Partial support
footnote The API exists but returns NS_ERROR_UNEXPECTED.
Firefox for Android – Full support
Firefox for Android 144 (Release date: 2025-10-14)
footnote Full support
Opera Android – Full support
Opera Android 25 (Release date: 2014-10-16)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 3 (Release date: 2015-04-10)
footnote Full support
WebView Android – Full support
WebView Android 38 (Release date: 2014-10-08)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Has more compatibility info.