Onload event handler

B

Brand

How many onload event handlers can you have in the below
the <body> tag?

One I suspect, and if so is there a workaround?

Thanks!
 
J

Jon Spivey

Hi,
as many as you like - seperated by ; eg

<body onload="functionOne(); functionTwo();">
or an alternative
<script type="text/javascript">
// your functions
function doIt(){
functionOne();
functionTwo();
}
onload=doIt;
</script>

Both do the same thing

Jon
Microsoft MVP - FP
 
K

Kevin Spencer

You can also execute any JavaScript functionality when the page loads by
simply not putting your scripting instructions into a function, and placing
your script anywhere in the body of the document.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
J

Jon Spivey

True - that wouldn't be onload though :)

Jon


Kevin said:
You can also execute any JavaScript functionality when the page loads
by simply not putting your scripting instructions into a function,
and placing your script anywhere in the body of the document.
 
K

Kevin Spencer

No, but interestingly, that is how ASP.Net does "onload" scripts (it places
them just before the </form> tag on the page). Using the body onload can be
tricky, depending upon the positioning of your scripts, and what browser
you're using.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Top