-
Notifications
You must be signed in to change notification settings - Fork 23.1k
Document UserActivation API #21285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Document UserActivation API #21285
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| title: Navigator.userActivation | ||
| slug: Web/API/Navigator/userActivation | ||
| page-type: web-api-instance-property | ||
| tags: | ||
| - API | ||
| - Property | ||
| - Reference | ||
| browser-compat: api.Navigator.userActivation | ||
| --- | ||
|
|
||
| {{APIRef("HTML DOM")}} {{SeeCompatTable}} | ||
|
|
||
| The read-only **`userActivation`** property of the {{domxref("Navigator")}} interface returns a {{domxref("UserActivation")}} object which contains information about the current window's user activation state. | ||
|
|
||
| ## Value | ||
|
|
||
| A {{domxref("UserActivation")}} object. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Checking if a user gesture was recently performed | ||
|
|
||
| Use {{domxref("UserActivation.isActive")}} to check wether the user is currently interacting with the page ({{Glossary("Transient activation")}}). | ||
|
|
||
| ```js | ||
| if (navigator.userActivation.isActive) { | ||
| // proceed to request playing media, for example | ||
| } | ||
| ``` | ||
|
|
||
| ### Checking if a user gesture was ever performed | ||
|
|
||
| Use {{domxref("UserActivation.hasBeenActive")}} to check wether the user has ever interacted with the page ({{Glossary("Sticky activation")}}). | ||
|
|
||
| ```js | ||
| if (navigator.userActivation.hasBeenActive) { | ||
| // proceed with auto-playing an animation, for example | ||
| } | ||
| ``` | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - {{domxref("UserActivation")}} | ||
| - {{domxref("UserActivation.hasBeenActive")}} | ||
| - {{domxref("UserActivation.isActive")}} | ||
| - [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: UserActivation.hasBeenActive | ||
| slug: Web/API/UserActivation/hasBeenActive | ||
| page-type: web-api-instance-property | ||
| tags: | ||
| - API | ||
| - Property | ||
| - Reference | ||
| browser-compat: api.UserActivation.hasBeenActive | ||
| --- | ||
|
|
||
| {{APIRef("HTML DOM")}} {{SeeCompatTable}} | ||
|
|
||
| The read-only **`hasBeenActive`** property of the {{domxref("UserActivation")}} interface indicates whether the current window has sticky user activation (see {{Glossary("sticky activation")}}). | ||
|
|
||
| ## Value | ||
|
|
||
| A boolean. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Checking if a user gesture was ever performed | ||
|
|
||
| Use the `hasBeenActive` property to check wether the user has ever interacted with the page. | ||
|
|
||
| ```js | ||
| if (navigator.userActivation.hasBeenActive) { | ||
| // proceed with auto-playing an animation, for example | ||
| } | ||
| ``` | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - {{domxref("UserActivation")}} | ||
| - {{domxref("UserActivation.isActive")}} | ||
| - [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| title: UserActivation | ||
| slug: Web/API/UserActivation | ||
| page-type: web-api-interface | ||
| tags: | ||
| - API | ||
| - Interface | ||
| - Reference | ||
| browser-compat: api.UserActivation | ||
| --- | ||
|
|
||
| {{APIRef("HTML DOM")}}{{SeeCompatTable}} | ||
|
|
||
| The **`UserActivation`** interface allows 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. 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: | ||
|
|
||
| - {{Glossary("Transient activation")}} (user is currently interacting with the page) and | ||
| - {{Glossary("Sticky activation")}} (user has interacted at least once since page load). | ||
|
|
||
| See [Features gated by user activation](/en-US/docs/Web/Security/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. | ||
|
|
||
| ## Properties | ||
|
|
||
| - {{domxref("UserActivation.hasBeenActive")}} {{ReadOnlyInline}} {{experimental_inline}} | ||
| - : Indicates whether the current window has sticky user activation. | ||
| - {{domxref("UserActivation.isActive")}} {{ReadOnlyInline}} {{experimental_inline}} | ||
| - : Indicates whether the current window has transient user activation. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Checking if a user gesture was recently performed | ||
|
|
||
| Use {{domxref("UserActivation.isActive")}} to check wether the user is currently interacting with the page ({{Glossary("Transient activation")}}). | ||
|
|
||
| ```js | ||
| if (navigator.userActivation.isActive) { | ||
| // proceed to request playing media, for example | ||
| } | ||
| ``` | ||
|
|
||
| ### Checking if a user gesture was ever performed | ||
|
|
||
| Use {{domxref("UserActivation.hasBeenActive")}} to check wether the user has ever interacted with the page ({{Glossary("Sticky activation")}}). | ||
|
|
||
| ```js | ||
| if (navigator.userActivation.hasBeenActive) { | ||
| // proceed with auto-playing an animation, for example | ||
| } | ||
| ``` | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - {{domxref("navigator.userActivation")}} | ||
| - [Features gated by user activation](/en-US/docs/Web/Security/User_activation) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: UserActivation.isActive | ||
| slug: Web/API/UserActivation/isActive | ||
| page-type: web-api-instance-property | ||
| tags: | ||
| - API | ||
| - Property | ||
| - Reference | ||
| browser-compat: api.UserActivation.isActive | ||
| --- | ||
|
|
||
| {{APIRef("HTML DOM")}} {{SeeCompatTable}} | ||
|
|
||
| The read-only **`isActive`** property of the {{domxref("UserActivation")}} interface indicates whether the current window has transient user activation (see {{Glossary("transient activation")}}). | ||
|
|
||
| ## Value | ||
|
|
||
| A boolean. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Checking if a user gesture was recently performed | ||
|
|
||
| Use the `isActive` property to check wether the user is currently interacting with the page. | ||
|
|
||
| ```js | ||
| if (navigator.userActivation.isActive) { | ||
| // proceed to request playing media, for example | ||
| } | ||
| ``` | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - {{domxref("UserActivation")}} | ||
| - {{domxref("UserActivation.hasBeenActive")}} | ||
| - [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.