Basically I have a table that I generating using javascript. I wrote a function to build the row and I call it a bunch of times with different parameters.

I know the individual functions work because I can pull them onto their own page and attach them to an onclick event with a button.

What I need to know is how to get the page to run the script/function when the page loads so the table is there when the user gets to the page.

I have tried using the onload event in the body tag but no luck so far.

Thanks in advance,

9 Years
Discussion Span
Last Post by toadzky

it will not work on onload event as dom tree has not been yet formed.

try this:
suppose function name is myFun(); then call it inside script block just after body tag , like this


Have you tried onLoad="javascript:myFun()" in the body tag?

You can also call the function with window.onLoad = myFun; inside the script block


Don't ask me why, but I finally got it working.

I just deleted everything out of the page and started from scratch. Which somehow made the onload event work. Thanks for the help everyone!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.