0

I have an image and code

$(thisSrc).click();

How I can to distinguish physic mouse click by user

$(thisSrc).on("click", function () {
});

from program by javascript?

 $(thisSrc).click();
user2560165
  • 149
  • 1
  • 2
  • 15
  • See also [Difference between .click() and actually clicking a button?](http://stackoverflow.com/q/11127908/710446) – apsillers Jul 15 '13 at 13:30
  • Also duplicate of [Determine whether a given JavaScript action has been initiated by user](http://stackoverflow.com/q/5948350/710446). – apsillers Jul 15 '13 at 13:32
  • http://stackoverflow.com/questions/6982072/click-source-in-javascript-and-jquery-human-or-automated - really work for me. just pass in an argument. thanks – user2560165 Jul 15 '13 at 13:38

2 Answers2

0

There is isTrigger key in event when it's triggered.

$(el).click(function(e) {
   if (e.isTrigger) {
      // triggered
   } else {
      // clicked by hand
   };
});
Tommi
  • 3,199
  • 1
  • 24
  • 38
-2

One way would be like this:

var realClick = true;

realClick=false;$(thisSrc).click();

$(thisSrc).on("click", function () {
// stuff
realClick=true;
});
Jonathan
  • 8,771
  • 4
  • 41
  • 78