When you use the call $('a').click();
, it is essentially a shortcut for $('a').trigger('click');
. This attempts to imitate a click action on the anchor element.
However, this simulation is not perfect. While it will trigger the event handler that has been registered, it does not fully replicate an actual user clicking and triggering the default action.
According to the jQuery documentation for trigger,
Description: Execute all handlers and behaviors attached to the
matched elements for the given event type.
and
Although .trigger() simulates an event activation, complete with a
synthesized event object, it does not perfectly replicate a
naturally-occurring event.
Therefore, it seems unlikely that using this method would allow you to completely simulate a user action and trigger a redirection.