function clickElement(htmlElement) {
var document = htmlElement.ownerDocument
var window = document.defaultView
var event = document.createEvent('MouseEvents')
event.initMouseEvent(
'click', // what type of event was it?
1, // does the event bubble?
1, // is the event cancelable?
window, // what window is it happening in?
1, // how many clicks were there?
0, // where on the screen is it (x coordinate)?
0, // where on the screen is it (y coordinate)?
0, // where in the window is it (x coordinate)?
0, // where on the window is it (y coordinate)?
0, // is the ctrl key down?
0, // is the alt key down?
0, // is the shift key down?
0, // is the meta key down?
0, // which button was pressed?
htmlElement) // what html element was it pressed in?
htmlElement.dispatchEvent(event)
}
Commentary