I use this code for generating mouse click in Web browser:
var element = document.getElementById('element_id');
var o = document.createEvent('MouseEvents');
o.initMouseEvent('click', true, true, window, 1, 12, 345, 7, 220, false, false, true, false, 0, null);
element.dispatchEvent(o);
It works, but I cannot understand what does 6th - 9th (12, 345, 7, 220) arguments do? When I change it - it doesn't change anything. I find in https://developer.mozilla.org
that these arguments are screenX
, screenY
, clientX
and clientY
coordinates, but what does that mean?
Those parameters are added to the event that is created. When you originally receive a mouseclick event you too get the current screenX/Y and clientX/Y coordinates of the event in the event object. This way you can fill those parameters. If they are not used when processing the event those will have no effect at all.
Simply put those parameters show where on the screen (screenx/y) and where within the browser boundaries (clientx/y) the click happened.
You can read about the parameters here:
https://developer.mozilla.org/en-US/docs/DOM/event.screenX
https://developer.mozilla.org/en-US/docs/DOM/event.screenY