UserActivation:hasBeenActive 属性

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.

UserActivation 接口的 hasBeenActive 只读属性表示当前的窗口是否有粘性用户激活

一个布尔值。

示例

检查是否执行过用户手势

使用 hasBeenActive 属性检查用户自加载页面以来是否与页面进行过交互。

js
if (navigator.userActivation.hasBeenActive) {
  // 例如,继续自动播放动画
}

规范

Specification
HTML
# dom-useractivation-hasbeenactive

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
hasBeenActive

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见