--- title: WakeLock slug: Web/API/WakeLock translation_of: Web/API/WakeLock ---
{{APIRef("Screen Wake Lock API")}}{{SeeCompatTable}}{{securecontext_header}}
WakeLock
接口允许一个文件获取屏幕唤醒锁定。
以下例子获取一个唤醒锁定并在 10 分钟后释放它:
function tryKeepScreenAlive(minutes) { navigator.wakeLock.request("screen").then(lock => { setTimeout(() => lock.release(), minutes * 60 * 1000); }); } tryKeepScreenAlive(10);
规范 | 状态 | Comment |
---|---|---|
Screen Wake Lock API | Editor's Draft | Initial definition |
{{Compat("api.WakeLock")}}