Click to See Complete Forum and Search --> : loading 2 functions in a document?
gokou
09-11-2003, 09:31 AM
I have two scripts, a date script and clock script. I'm trying to call both of the functions, but I only know how to call one of them using onload in the body tag. I tried "document.body.onload", but that's just the same. What's the other ways of calling the function?
Thanks.
gokou
09-11-2003, 09:48 AM
I feel stupid. Just writing the function calls it.
I was tired when posting this and posted it in the wrong thread, sorry.
As you found out, you can only have on onload directly in the script, so you will have to do one of these two things:
1: put both functions in the <body>'s onload, like this: <body onload="functionOne(); functionTwo();">
2: in the onload event, run a function that will in turn call your other functions:
<script type="text/javascript">
function functionOne() {
alert ("One");
}
function functionTwo() {
alert ("Two");
}
window.onload = function() {
functionOne();
functionTwo();
}
</script>