Call a javascript function on page load

Please let me know how I can call a javascript function automatically when the page loads.
Thanks!
dshrenikAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
chaitu chaituConnect With a Mentor Commented:
<body onload="ex()">

or

window.onload=ex();
0
 
Gurvinder Pal SinghConnect With a Mentor Commented:
or also

window.onload = function(){
  //invoke code here
  alert("page loaded");
};
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.