I recently programmed a menu interface for javascript that lets you dynamically add options to it and mostly works with mouseEnter Events . I thne added some basic video Controls to it with request/exit Fullscreen that trigger on one of these mouseEnter events most of the time it displays Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
however (weird part :) sometimes it works and im not sure how the browser api decides wether an action is a user gesture or not oO any help would be appreciated thanks
edited. Chromium has a notion of a "user gesture" which indicates that we believe the user is explicitly interacting with the page (eg. mouse click, but not mouse move or wheel). Then certain sensitive operations are restricted to apply only if it can "consume" a user gesture (eg. one successful window.
You may get this error if you are trying to have the player execute an action without it being initiated by the user. A typical example is going fullscreen or automatically starting playback (often on mobile).
Here is the list of events that can trigger "by user activation" as defined by the specs:
- change
This is what your error message refers to when they say "a user gesture".
mouseenter
is not part of this list.
Most likely, when it worked, it was because one of those event did happen less than a few ms before (IIRC it's 50ms in Chrome currently).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With