Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make onclick automatically through onload function

I have a href link and I would like it to be clicked when the page is loaded.

like image 759
Haim Evgi Avatar asked Jul 08 '09 13:07

Haim Evgi


People also ask

Is onload an event handler attribute?

Definition and Usage. The onload attribute fires when an object has been loaded. onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.).

Which function works when we click on to the execution button?

The onclick event executes a certain functionality when a button is clicked. This could be when a user submits a form, when you change certain content on the web page, and other things like that.

Can I use onload with Div?

The onload event can only be used on the document(body) itself, frames, images, and scripts. In other words, it can be attached to only body and/or each external resource. The div is not an external resource and it's loaded as part of the body, so the onload event doesn't apply there.


1 Answers

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

Or

$(document).ready(function() {
   $('#someLinkId').trigger("click");
});
like image 146
karim79 Avatar answered Oct 04 '22 20:10

karim79