Web APIs

Page Visibility API

Checking compatibility...

Detect when a webpage becomes visible or hidden to the user, enabling better resource management and user experience optimization.

Note: Check your browser support for the Page Visibility API. Most modern browsers support this feature.

Page Visibility Events

Detect when users switch away from or return to your page. This example shows how to monitor visibility changes when someone switches tabs, minimizes their browser, or returns to your page after looking at something else.

=
=
=
=
=
=

Output

Click Run to see output...

Page Visibility Actions

Respond intelligently when your page is hidden or visible. This example demonstrates how to automatically pause video playback when someone switches away from your page and resume it when they return.

=
=
=
=
=
=

Output

Click Run to see output...