Here you can find the source of triggerEvent(eventName)
Element.prototype.triggerEvent = function(eventName){ if (document.createEvent) {// w w w .ja v a 2 s . com var evt = document.createEvent('HTMLEvents'); evt.initEvent(eventName, true, true); return this.dispatchEvent(evt); } if (this.fireEvent) return this.fireEvent('on' + eventName); }