Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Intermediate
Apr 27, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Calling a Script Function Without User Input

The most common way to call a script function is to have an element trap an event, which in turn calls the function, as in:

<DIV id = "myelement" onclick = "myfunction()" > Click here </DIV>

But what if you want a function to perform a task as soon as the page loads without any user input? In that case, you can use the onload event, placing it in the Body element of your page, as in:

<BODY onload = "myfunction()" > 
The function will be called immediately after the page loads, and no user input is required.

Manoj K.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date