/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Method to fire DOM0 events such as onblur, onfocus, onchange function fireEvent(element,event){ if(document.createEvent){ var evt = document.createEvent("HTMLEvents"); evt.initEvent(event,true,true); return !element.dispatchEvent(evt); } else if(document.createEventObject) { var evt = document.createEventObject(); return element.fireEvent('on'+event,evt); } };