Draft
This page is not complete.
Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The WakeLock
interface of the Screen Wake Lock API
prevents device screens from dimming or locking when an application needs to keep running.
The system wake lock is exposed through the global Navigator.wakelock
property.
Methods
request
- Requests a
WakeLockSentinel
object, which returns aPromise
that resolves with aWakeLockSentinel
object.
Examples
The following asynchronous function requests a WakeLockSentinel
object. The WakeLock.request
method is wrapped in a try...catch
statement to account for if the browser refuses the request for any reason.
const requestWakeLock = async () => { try { const wakeLock = await navigator.wakeLock.request('screen'); } catch (err) { // the wake lock request fails - usually system related, such low as battery console.log(`${err.name}, ${err.message}`); } } requestWakeLock();
Specifications
Specification | Status | Comment |
---|---|---|
Screen Wake Lock API The definition of 'WakeLock' in that specification. |
Unknown | Initial definition. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
WakeLock | Chrome Full support 84 | Edge Full support 84 | Firefox No support No | IE No support No | Opera Full support Yes | Safari No support No | WebView Android Full support 84 | Chrome Android Full support 84 | Firefox Android No support No | Opera Android Full support Yes | Safari iOS No support No | Samsung Internet Android Full support Yes |
request | Chrome Full support 84 | Edge Full support 84 | Firefox No support No | IE No support No | Opera Full support Yes | Safari No support No | WebView Android Full support 84 | Chrome Android Full support 84 | Firefox Android No support No | Opera Android Full support Yes | Safari iOS No support No | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support