Skip to content

Instantly share code, notes, and snippets.

@eligrey
Created June 24, 2011 04:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eligrey/1044231 to your computer and use it in GitHub Desktop.
Save eligrey/1044231 to your computer and use it in GitHub Desktop.
document.click(x, y) to click the element at specific coords
document.click = function(x, y) {
"use strict";
var
doc = this
, node = doc.elementFromPoint(x, y)
, click = doc.createEvent("UIEvent")
;
click.initUIEvent("click", true, true, self, 1);
return node.dispatchEvent(click);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment