Yes, you can simulate a mouse click by creating an event and sending it:
function click(x,y){ var ev = document.createEvent("MouseEvent"); var el = document.elementFromPoint(x,y); ev.initMouseEvent( "click", true , true , window, null, x, y, 0, 0, false, false, false, false, 0 , null ); el.dispatchEvent(ev); }
Beware of using the click method for an element - it is widely implemented, but it is not standard and will not work, for example. PhantomJS. I assume that the jQuery .click() implementation does the right thing, but is not confirmed.
user663031 May 12 '13 at 16:32 2013-05-12 16:32
source share