Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.

 

 

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