Click to See Complete Forum and Search --> : Running a function onLoad


karayan
07-26-2003, 02:34 PM
I need to run a function after the document has finished loading, but I CANNOT include the onLoad even handler in the <body> tag. (The reason is, there are times the file will be opened and the javascript will not be loaded at all -- thus, the onLoad handler wil not be found.) So, my script reads like this:


document.captureEvents(Event.LOAD);

document.onLoad = AWS_start();

where AWS_start() is the function I want to run. IE tells me that Event is undefined. Netscape has no problem with the code. What am I doing wrong?

Charles
07-26-2003, 02:48 PM
window.onload = AWS_start;

Note that it's "onload" and not "onLoad" and that it's a method of the "window" object and not of the "document" object. Note also that you want to assign the function to the handler and not what the function returns so omit the "()".