Screen Wake Lock API
The release event of the WakeLockSentinel interface is fired when the sentinel object's handle has been released.
A WakeLockSentinel can be released manually via the release() method, or automatically via the platform wake lock.
This can happen if the document becomes inactive or loses visibility, if the device is low on power or the user turns on a power save mode.
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("release", (event) => { })
Alternatively, assign to the event handler property of the interface:
onrelease = (event) => { }
Event type
A generic Event.
Examples
This example updates the UI if the wake lock is released.
wakeLock.addEventListener("release", () => {
// if wake lock is released alter the UI accordingly
statusElement.textContent = "Wake Lock has been released";
});
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
