2

so I'm trying simulate real mouse click, but nothing goes well... i tried lot of ways but still can't simulate it. please tell me is possible simulate real mouse click with javascript? if yes give me some hints.

    function click(x,y){
        var ev = document.createEvent("MouseEvent");
        var el = document.elementFromPoint(x,y);
        ev.initMouseEvent(
            "click",
            true /* bubble */, true /* cancelable */,
            window, null,
            x, y, 0, 0, /* coordinates */
            false, false, false, false, /* modifier keys */
            0 /*left*/, null
        );
        el.dispatchEvent(ev);
    }

click(100,100);

this is my last try but it is not same as real click. i saw this topic on stackoverflow which have same idea but it is old and if is some new way to do this kind of stuff please help me.

2
  • 4
    stackoverflow.com/questions/6157929/… Commented Dec 13, 2016 at 11:50
  • i tested it and it does not works for me, does it depends browser type? and version? i'm testing on chrome Version 49.0.2623.112 m Commented Dec 13, 2016 at 12:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.