Emulate clicking a link with Javascript that works with IE

I think you still need to call document.createEventObject — you only checked that it’s there. Untested code follows, but based on the docs it should work.

function fireEvent(obj,evt){

    var fireOnThis = obj;
    if( document.createEvent ) {
      var evObj = document.createEvent('MouseEvents');
      evObj.initEvent( evt, true, false );
      fireOnThis.dispatchEvent( evObj );

    } else if( document.createEventObject ) {
      var evObj = document.createEventObject();
      fireOnThis.fireEvent( 'on' + evt, evObj );
    }
}

Leave a Comment