My website has the functionality to take screenshots with share screen functionality. On chrome and firefox everything works fine, but on safari i get an error "getDisplayMedia must be called from a user gesture handler". Is it possible to simulate user gesture from within the code itself? I have tried to use myButton.click()
, but it doesn't register as an user gesture.
It is not possible to generate a user gesture from within the code. This safari error occures due to the event (event that should trigger it) having isTrusted property false. This property is set automatically and is not possible to fake. If you do a genuine user gesture this property is true, if you invoke an event from within the code it's false. In my case I simply generated a panel with backdrop asking for confirmation to take the screenshot to invoke this action with a genuine user gesture.
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