[ACCEPTED]-How to make onclick automatically through onload function-onclick

Accepted answer
Score: 20
$(document).ready(function() {
   $('#someLinkId').click();
});

Or

$(document).ready(function() {
   $('#someLinkId').trigger("click");
});

0

Score: 3

$("#whateverid").trigger("click");

Where "whateverid" is the ID of the anchor 2 tag, or whatever other selector you want 1 to use.

Score: 3
$(document).ready(function () {
   $("#myLink").trigger('click');
});

as you can read in: http://docs.jquery.com/Events/trigger#eventdata

0

Score: 2

What's the point of loading the page if 3 you're going to navigate away from it immediately?

In 2 addition to jQuery's triggering abilities, you 1 could do:

<body onload="window.location.replace('http://example.com/');">

or:

<body onload="window.location.href = 'http://example.com/';">

More Related questions