Simulating click with javascript on document
        Posted  
        
            by Charlie
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Charlie
        
        
        
        Published on 2010-05-23T07:11:04Z
        Indexed on 
            2010/05/23
            7:20 UTC
        
        
        Read the original article
        Hit count: 312
        
Is it possible to simulate a click on a webpage using javascript but without defining a specific element, but rather just specifying the document?
I would have liked to do something like this, and if the location happens to have a link, then this will be pressed:
function simulateClick(x, y) 
{
    var evt = window.createEvent("MouseEvents");
    evt.initMouseEvent("click", true, true, window,
        x, y, x, y, 1, false, false, false, false, 0, null);
    window.dispatchEvent(evt);
}
© Stack Overflow or respective owner