Example 1 — Read Both Flags
Feature-detect and print transient vs sticky state.
if (!navigator.userActivation) {
console.log("userActivation unavailable");
} else {
console.log("isActive:", navigator.userActivation.isActive);
console.log("hasBeenActive:", navigator.userActivation.hasBeenActive);
} How It Works
- Detect. Older environments may not expose the property.
- Read
isActive. Transient activation for the current gesture window. - Read
hasBeenActive. Sticky flag for any prior interaction since load. - Timing matters. Running this on cold load often prints two
falsevalues.

