Posted By

Jamie on 12/07/09


Tagged


Versions (?)

DOM Level 0 "Fire Event"


 / Published in: JavaScript
 

  1. // Method to fire DOM0 events such as onblur, onfocus, onchange
  2. function fireEvent(element,event){
  3. if(document.createEvent){
  4. var evt = document.createEvent("HTMLEvents");
  5. evt.initEvent(event,true,true);
  6. return !element.dispatchEvent(evt);
  7. } else if(document.createEventObject) {
  8. var evt = document.createEventObject();
  9. return element.fireEvent('on'+event,evt);
  10. }
  11. };

Report this snippet  

You need to login to post a comment.