src/lib/demo.js
function(element, type, handler) {
    if(element.addEventListener) {
      addEvent = function(element, type, handler) {
        element.addEventListener(type, handler, false);
      };
    } else if(element.attachEvent) {
      addEvent = function(element, type, handler) {
        element.attachEvent('on' + type, handler);
      };
    } else {
      addEvent = function(element, type, handler) {
        element['on' + type] = handler;
      };
    }
    addEvent(element, type, handler);
  }
function(element, type, handler) {
    if(element.addEventListener) {
      addEvent = function(element, type, handler) {
        element.addEventListener(type, handler, false);
      };
    } else if(element.attachEvent) {
      addEvent = function(element, type, handler) {
        element.attachEvent('on' + type, handler);
      };
    } else {
      addEvent = function(element, type, handler) {
        element['on' + type] = handler;
      };
    }
    addEvent(element, type, handler);
  }
function ( element , type , handler ) { if ( element . addEventListener ) { addEvent = function ( element , type , handler ) { element . addEventListener ( type , handler , false ) ; } ; } else if ( element . attachEvent ) { addEvent = function ( element , type , handler ) { element . attachEvent ( 'on' + type , handler ) ; } ; } else { addEvent = function ( element , type , handler ) { element [ 'on' + type ] = handler ; } ; } addEvent ( element , type , handler ) ; }
Cross-browser compatible event handler.
Cross - browser compatible event handler .