Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine whether a given JavaScript action has been initiated by user

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?

like image 604
mgamer Avatar asked May 10 '11 09:05

mgamer


People also ask

How do you check if an event has been triggered in JavaScript?

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.

Which action is done by users in JavaScript?

a) Events are the actions done by users or an application that occurs on the webpage.

What is function E in JavaScript?

"function(e)" is the event handling function (on event, object is created). "e" is the object handler (object is made accessible).


1 Answers

event.which will be undefined if the event is triggered with code.

jsFiddle.

like image 148
alex Avatar answered Sep 29 '22 02:09

alex