recorder.js
function trigger(el, name, options){
  var event, type;
  
  type = eventTypes[name];
  if (!type) {
    throw new SyntaxError('Unknown event type: '+type);
  }
  
  options = options || {};
  inherit(defaults, options);
  
  if (document.createEvent) {
    // Standard Event
    event = document.createEvent(type);
    initializers[type](el, name, event, options);
    el.dispatchEvent(event);
  } else {
    // IE Event
    event = document.createEventObject();
    for (var key in options){
      event[key] = options[key];
    }
    el.fireEvent('on' + name, event);
  }
}
function trigger(el, name, options){
  var event, type;
  
  type = eventTypes[name];
  if (!type) {
    throw new SyntaxError('Unknown event type: '+type);
  }
  
  options = options || {};
  inherit(defaults, options);
  
  if (document.createEvent) {
    // Standard Event
    event = document.createEvent(type);
    initializers[type](el, name, event, options);
    el.dispatchEvent(event);
  } else {
    // IE Event
    event = document.createEventObject();
    for (var key in options){
      event[key] = options[key];
    }
    el.fireEvent('on' + name, event);
  }
}
function trigger ( el , name , options ) { var event , type ; type = eventTypes [ name ] ; if ( ! type ) { throw new SyntaxError ( 'Unknown event type: ' + type ) ; } options = options || { } ; inherit ( defaults , options ) ; if ( document . createEvent ) { // Standard Event event = document . createEvent ( type ) ; initializers [ type ] ( el , name , event , options ) ; el . dispatchEvent ( event ) ; } else { // IE Event event = document . createEventObject ( ) ; for ( var key in options ) { event [ key ] = options [ key ] ; } el . fireEvent ( 'on' + name , event ) ; } }
Trigger a DOM event.

trigger(document.body, "click", {clientX: 10, clientY: 35});

Where sensible, sane defaults will be filled in.  See the list of event
types for supported events.

Loosely based on:
https://github.com/kangax/protolicious/blob/master/event.simulate.js
Trigger a DOM event .