one man army wrote:
> What else can I use besides onload() that will be called when I enter a
> page? If there is one, is the order betweenthe two _types_ of events
> prescribed?
>
> reason- I am having a problem with a third party API in which it gets
> confused when I init it in doc.onload(), then make a bunch of calls
> before it gets a chance to draw the first time. I want to split the code
> to let it init, then make the calls, but all on upon entering the page.
window.onload handler call merely means that DOM structure is ready so
you can address page elements using getElementById and other DOM
methods. For any underlaying elements (Flash, 3rd party API's, movies,
images) you have to listen for load event from these elements
themselve. So you reverse the algorithm: not the window is asking
loaded/not, but elements inform interested listeners.
<body onload=""> however attractively simple it is, is not suitable for
more or less complicated synchronization tasks. You can use the
suggested delay, but it is not clear why do you think that 500ms delay
will be enough guaranteed on any system? And if API failed to init
(onerror) then even timeout Infinity will not suffice. ;-)
If you really on a deadline then put delay like 1500ms, cross your
fingers and let it go... really not suggested, but may fly on the show
up systems.
Received on Tue Feb 7 21:30:31 2006