This is non-trivial because you need to fake event objects and require different code for different browsers. Luckily, there is tool support for most types of events.
In jQuery you can say:
$('a#close_window').click();
In Prototype you can use event.simulate.js Show archive.org snapshot from the Protolicious library to say:
$$('a#close_window')[0].simulate('click');
To trigger custom events with Prototype, you can use the
built-in Element.fire()
Show archive.org snapshot
function. In Prototype, custom events MUST be namespaced.
this.fire('custom:event');
Posted by Henning Koch to makandra dev (2010-11-18 17:17)