不是我的原创,从网上看到的。 http://snipplr.com/view/8471/manually-trigger-element-event-via-code/
< a href = " # "  onclick = " alert('onclick executed'); "  id = " testLink " > some link </ a >
 
< script type = " text/javascript " >
<!--
function fireEvent(element, eventName) {
    evt 
=  document.getElementById(element)[eventName];
 
    
if  (typeof(evt)  ==   " function " ) {
        document.getElementById(element)[eventName]();
    } 
else  {}
}
 
 
fireEvent(
" testLink " " onclick " );
-->
</ script >