Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  106] [ 6]  / answers: 1 / hits: 34758  / 12 Years ago, mon, september 17, 2012, 12:00:00

Possible Duplicate:

Javascript that executes after page load






how to call a javascript method as soon as page is loaded.



i have a java script which needs to be called soon after the jsp page is loaded, how to achieve this in javascript.



could any one of you help me pelase.



Regards


More From » jsp

 Answers
47

You can write a code snippet something like this :-



window.onload(function(){
//Your JavaScript here
});


And if using JQuery then



document.ready(function(){
//Your JavaScript Here
});


Or you can have all your JS after all the HTML.



you can even use a function called :--



document.onload(function(){
//Your code Here
});


Last but not the least you could even try out this



 <body onload=YourJSMethod();>
<!-- Some html content -->
</body>

[#83051] Friday, September 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deanna

Total Points: 84
Total Questions: 86
Total Answers: 107

Location: Cyprus
Member since Wed, Dec 8, 2021
3 Years ago
;