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.
Instance methods
-
request()
-
Requests a WakeLockSentinel object, which returns a Promise that resolves with a WakeLockSentinel 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.
try {
const wakeLock = await navigator.wakeLock.request("screen");
} catch (err) {
console.log(`${err.name}, ${err.message}`);
}
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
WakeLock |
84 |
84 |
No |
No |
70 |
16.4 |
84 |
84 |
No |
60 |
16.4 |
14.0 |
request |
84 |
84 |
No |
No |
70 |
16.4 |
84 |
84 |
No |
60 |
16.4 |
14.0 |