Is it possible to determine whether a given JavaScript action has been initiated by user? For instance I want to know whether a link was clicked by user or via jQuery fire event method?
To check if event is triggered by a human with JavaScript, we can use the isTrusted property. to check if the event is triggered by a human in our event handler callback. e is the event object and it had the isTrusted property. If isTrusted is true , then the event is triggered by a human.
a) Events are the actions done by users or an application that occurs on the webpage.
"function(e)" is the event handling function (on event, object is created). "e" is the object handler (object is made accessible).
event.which
will be undefined
if the event is triggered with code.
jsFiddle.
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