/ Published in: JavaScript

Let you fire click events on any html element.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
HTMLElement.prototype.click = function() { if (document.createEvent) { var evt = this.ownerDocument.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt); } else if (this.fireEvent) { this.fireEvent("onclick"); } } // usage // <a href="http://www.barattalo.it" id="linktoclick">auto click</a> document.getElementById("linktoclick").click();
URL: http://www.barattalo.it/2009/11/18/click-links-with-javascript/
Comments
