body onLoad - what does it do ?

E

Emmanuel Papillon

Hello.

I've got a page with sound through a swf file, working with an animation
with preloaded JPEG files (animated through use of setTimeout).

I'm preloading the JPEG files through Javascript in the <head> tag, the
Flash animation/sound file being in the <object> & <embed> tags.

I'd like to fire the sound and JPEG animation once everything is loaded :
the page content, the JPEG files (stored in an array), and the swf file.

My question is : how does the onLoad body tag work ? I know it
covers the document content itself, probably the Flash animation, but
does it cover the preloaded image files stored through Javascript ?

I've found no clear answer on this. Thanks for replying.

--

Je suis le ciel, je suis la mer,
Je suis les mirages du désert,
Je suis ta dernière image avant de mourir,
Je suis ta ville imaginaire.

Je suis ce qui a été, ce qui est et ce qui sera,
Et quand je partirai tout partira avec moi.

Je suis Dieu, je ne suis rien,
Je suis Simbabbad de Batbad !

Emmanuel Papillon - http://www.batbad.com
 
M

Michael Winter

On Tue, 27 Apr 2004 01:05:23 +0200, Emmanuel Papillon

[snip]
My question is : how does the onLoad body tag work ?

You mean the load (or onload) intrinsic event in the BODY element?
I know it covers the document content itself, probably the Flash
animation, but does it cover the preloaded image files stored through
Javascript ?

I've found no clear answer on this. [...]

Probably because there isn't one. The load intrinsic event is defined as
firing "when the user agent finishes loading a window or all frames within
a FRAMESET." This tends to be interpreted differently by each browser
manufacturer. Some will fire when the document (the HTML) has been parsed
completely. Some when the HTML and all images are loaded. Some may extend
it to all objects and applets.

About the only thing you can probably anticipate is that the load event
won't wait for your preloading script. The script will certainly have
started, but it probably won't have finished unless there is little to
preload, or the user has a very fast connection.

[snip]

Mike
 
B

Brian Genisio

Michael said:
[snip]
About the only thing you can probably anticipate is that the load event
won't wait for your preloading script. The script will certainly have
started, but it probably won't have finished unless there is little to
preload, or the user has a very fast connection.

I do not think this is completely correct. Scripts are executed
serially. The script that does the preloading will be executed
completely before an onLoad event occurs. Only if a script is using
setTimeout or the DEFER attribute, will this not be the case.

The OP states that he uses setTimeout for animation of the images, and
not for preloading.

There is one issue with this... Just because the script has executed
completely, does not mean that the image has been loaded. When you make
a request of any type, the request is not guaranteed to happen
immediately. So, creating a new image, and setting the SRC attribute
will request that the browser load the image. This can take a long
time, so the assignemnt returns immediately, and the script may continue
to execute. So, when the onLoad happens, you can be pretty sure that
the script has executed, but there is no guarantee that the images have
been loaded yet.

Brian
 
M

Michael Winter

Michael said:
[snip]
About the only thing you can probably anticipate is that the load event
won't wait for your preloading script. The script will certainly have
started, but it probably won't have finished unless there is little to
preload, or the user has a very fast connection.

I do not think this is completely correct. Scripts are executed
serially. The script that does the preloading will be executed
completely before an onLoad event occurs. Only if a script is using
setTimeout or the DEFER attribute, will this not be the case.

[snip]

I meant total execution of the script which would include its side-effects
- in this case, the loading of images. From what I've observed, if a
script is present in the HEAD of a document, the BODY won't have even
begun parsing until that script has executed...
There is one issue with this... Just because the script has executed
completely, does not mean that the image has been loaded. When you make
a request of any type, the request is not guaranteed to happen
immediately. So, creating a new image, and setting the SRC attribute
will request that the browser load the image. This can take a long
time, so the assignemnt returns immediately, and the script may continue
to execute. So, when the onLoad happens, you can be pretty sure that
the script has executed, but there is no guarantee that the images have
been loaded yet.

....so I totally agree with what you're saying: the script will have
executed (the browser will wait that long), but will probably not have
"finished".

My apologies for not being clear,
Mike
 
E

Emmanuel Papillon

The OP states that he uses setTimeout for animation of the images, and
not for preloading.

The setTimeout instructions fire only after the onLoad event.

The loading function in the <head> is something like :

--

function initialise_tableau(tableau,img_nb,nom_img)
{
for (i=0;i<=img_nb-1;i++)
{
tableau=new Image;
tableau.src=nom_img + (i+1) + ".jpg";
}
}

initialise_tableau(tableau_levier,nb_img,"levier_");

--

The launching function is something like :

--

function subst_etape()
{
document.LEVIER.src=tableau_levier[etape].src;

if(etape<=nb_img-2) etape++;

return true;
}

function LEVIER_JOURNEY()
{
for (i=0;i<=nb_img-1;i++)
{
setTimeout('subst_etape()',i*(latence-i));
}

return true;
}

--

And it fires with :

--

<body bgcolor="#121212" onLoad="document.levier_swf.Play()">

--

... the Flash file triggering LEVIER_JOURNEY() through FScommand once fired.

My question is : is the onLoad event working for :

1) The HTML page code (obviously yes)

2) The page HTML body content

3) The Flash file

4) The preloaded images in the header

Thanks.
 
E

Emmanuel Papillon

Emmanuel Papillon said:
My question is : is the onLoad event working for :

1) The HTML page code (obviously yes)

2) The page HTML body content

3) The Flash file

4) The preloaded images in the header

Thanks.

Never mind. I made some simple test renaming files with a wrong name
so that the Flash animation or the preloaded images never finish loading.

For those interested, here's my results :

3) IE : yes, NS : no

4) IE : no, NS : no

Guess I won't trust onLoad on this and do my own checking !

:)

Thanks to those who answered.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top