WakeLockSentinel: release イベント

Baseline 2025
Newly available

Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

releaseWakeLockSentinel インターフェイスのイベントで、この見張りオブジェクトのハンドルが解放されたときに発行されます。

WakeLockSentinelrelease() メソッドにより手動で解放したり、プラットフォームの起動ロックにより自動的に解放されたりします。これは、文書がアクティブでなくなった場合や、見えなくなった場合、端末の電力が低下した場合、ユーザーが省電力モードをオンにした場合に発生する可能性があります。

構文

このイベント名を addEventListener() などで用いるか、イベントハンドラープロパティを設定するかしてください。

js
addEventListener("release", (event) => {});

onrelease = (event) => {};

イベント型

一般的な Event です。

この例では、起動ロックが解放されたときに UI を更新します。

js
wakeLock.addEventListener("release", () => {
  // if wake lock is released alter the UI accordingly
  statusElement.textContent = "Wake Lock has been released";
});

仕様書

Specification
Screen Wake Lock API
# the-onrelease-attribute

ブラウザーの互換性