W3cubDocs

/Web APIs

Navigator: userActivation property

The read-only userActivation property of the Navigator interface returns a UserActivation object which contains information about the current window's user activation state.

Value

A UserActivation object.

Examples

Checking if a user gesture was recently performed

Use UserActivation.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

Use UserActivation.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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
userActivation 72 79 No No 60 16.4 72 72 No 51 16.4 11.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userActivation