We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

marcio on 02/15/08


Tagged

javascript events EventHandler


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

iTony


add event


Published in: JavaScript 


  1. function hazCosasMaravillosasConElDOM() {}
  2.  
  3. //addEvent() by John Resig
  4. function addEvent( obj, type, fn ){
  5. if (obj.addEventListener){
  6. obj.addEventListener( type, fn, false );
  7. }
  8. else if (obj.attachEvent){
  9. obj["e"+type+fn] = fn;
  10. obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); }
  11. obj.attachEvent( "on"+type, obj[type+fn] );
  12. }
  13. }
  14.  
  15. addEvent(window, 'load', hazCosasMaravillosasConElDOM);

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: sosof on February 17, 2008

good

You need to login to post a comment.