The UserActivation
interface allows querying 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. Typically, this is a click on a button or some other user interaction with the UI.
There are two kinds of window user activation states:
See Features gated by user activation for more information and a list of APIs that require either sticky or transient user activation.
This API is only available in the window context and not exposed to workers.
Instance properties
UserActivation.hasBeenActive
Read only
-
Indicates whether the current window has sticky user activation.
UserActivation.isActive
Read only
-
Indicates whether the current window has transient user activation.
Examples
Use UserActivation.isActive
to check whether the user is currently interacting with the page (Transient activation).
if (navigator.userActivation.isActive) {
}
Use UserActivation.hasBeenActive
to check whether the user has ever interacted with the page (Sticky activation).
if (navigator.userActivation.hasBeenActive) {
}
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 |
hasBeenActive |
72 |
79 |
No |
No |
60 |
16.4 |
72 |
72 |
No |
51 |
16.4 |
11.0 |
isActive |
72 |
79 |
No |
No |
60 |
16.4 |
72 |
72 |
No |
51 |
16.4 |
11.0 |
See also