Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. UserActivation

UserActivation

Baseline 2023
Newly available

Since ⁨November 2023⁩, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

TheUserActivation interface provides information about whether a user is currently interacting with the page, or has completed an interaction since page load.

This API is only available in the window context and not exposed to workers.

Instance properties

UserActivation.hasBeenActiveRead only

Indicates whether the current window has sticky user activation.

UserActivation.isActiveRead only

Indicates whether the current window has transient user activation.

Description

An object of this type is accessed via thenavigator.userActivation property, and can be used to query information about a window's user activation state.

A user activation either implies that the user is currently interacting with the page, or has completed an interaction since page load.User activation can be triggered by a button click, pointer touch, or some other user interaction with the page.

There are two kinds of window user activation states:

SeeFeatures gated by user activation for more information and a list of APIs that require either sticky or transient user activation.

Examples

Checking if a user gesture was recently performed

Usenavigator.userActivation to access theUserActivation object, and thenUserActivation.isActive to check whether the user is currently interacting with the page (Transient activation).

js
if (navigator.userActivation.isActive) {  // proceed to request playing media, for example}

Checking if a user gesture was ever performed

UseUserActivation.hasBeenActive to check whether the user has ever interacted with the page (Sticky activation).

js
if (navigator.userActivation.hasBeenActive) {  // proceed with auto-playing an animation, for example}

Specifications

Specification
HTML
# the-useractivation-interface

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp