can I create a function that takes x and y coordinates, and will click the document at those coordinates?
by looking at this question I set up some sample code in a jsfiddle, here is that code (it does not work)
var e = new jQuery.Event("click");
e.pageX = 10;
e.pageY = 10;
$("button").click(function(){
$(document).trigger(e);
});
what I thought the above code would do is click in the document at position (10,10), and because that section of the document is where the item that needs to be clicked is, it should do the same as would clicking the item. But it does not...what am I doing wrong?
why
why would I do this when I could just simply do something like:
$("button").click(function(){
$('.box').click();
});
well in certain circumstances, that is not possible. for example, clicking a specific div inside an iframe outside of the domain. I cannot click what is inside it through code because I don't have access to it's body. But if I know the position of that div in my own document and force the viewer to click over it, then that would work!