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
Asked
Active
Viewed 6,014 times
9

jonathan Heindl
- 844
- 7
- 16
-
a current suspicion I have is that its more likely to work directly at site startup (maybe its a timing thing and the code executes faster without having loaded too much else ) – jonathan Heindl May 31 '19 at 03:22
2 Answers
13
Here is the list of events that can trigger "by user activation" as defined by the specs:
- change
- click
- contextmenu
- dblclick
- mouseup
- pointerup
- reset
- submit
- touchend
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).

demoncodemonkey
- 11,730
- 10
- 61
- 103

Kaiido
- 123,334
- 13
- 219
- 285
0
For what this is worth, I've been consistently successful triggering actions that require user gestures when using addEventListener()
calls to monitor for user events on elements. I've not been successful using the old onClick
attributes to specify an event for an element.

CrazyIvan1974
- 377
- 1
- 2
- 11