Hi,

Basically, this won't work in a normal script block:

Event.observe($$('body')[0], 'load', function() {
    bodyOnLoad();
);

...because when it runs, the DOM isn't loaded yet, so you can't locate
the body element (or any other; that's what dom:loaded is for, to tell
us when the DOM is ready). In fact, short of using the onload
attribute, you'd have to get the timing *exactly* right to get in
there after the DOM was ready but before the body.load event had
already been fired. Could the MooTools folks be faking it? :-) (E.g.,
saving up the request and the processing it on DOM load, firing the
event synthetically?)

What's the use case? Between dom:loaded and window.load, is there
really any need for body.load?
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Apr 1, 1:21 pm, matths <[email protected]> wrote:
> Hello!
>
> Thinking about events fired when a webpage is loaded, I would expect
> these events in exact this order:
>
> domReady
> body.onLoad
> window.onLoad
>
> Now, all I want to do, is to observe this events unobtrusivly using
> prototypejs. (with MooTools this is possible, but I need to use
> prototype for my current project)
>
> So far, I have:
> document.observe('dom:loaded', function() {
>         alert('DOM.ready')
>         Event.observe(window, 'load', function() {
>                 alert('window.onload');
>         });
>
> });
>
> The inline onLoad event (<body onload="alert('body.onLoad')">) works
> well.
> But I can't observe the onload event from the body. I am using
> prototypejs 1.6.1. How can I listen for that event?
>
> What I've tried so far:
> Event.observe($$('body')[0], 'load', function() {
>         bodyOnLoad();
>
> });
>
> Any ideas welcome.
>
> Regards,
> Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to