It depends on what you want to do.

If you're only interesting in the DOM tree then dom:loaded if great
since it doesn't have to wait until all assets (like images, flash
etc) are loaded before kicking in. But if you want to interact with
the images and, let say, check their dimensions or something like
that, its a good idea to let them load first.

I often end up with one listener for the DOM (dom:loaded) which start
listeners for DOM events since I want to do this as soon as possible
(like hijack links) and another for the full document (window.onload)
for things like...maybe fix png-images to work on IE6

Also, if you have scripts that will change the DOM in any way (like
how many adsystem does with document.write) you might want to wait for
window.unload before using the DOM tree too much, or at least test it
carefully, but YMMV.

Ciao
Martin


Sent from my computer

On 18/10/2007, Richard Quadling <[EMAIL PROTECTED]> wrote:
>
> Hi.
>
> Just trying out Prototype V1.6.0rc1.
>
> Which is "better" of these observers?
>
> Event.observe(window, 'load', function() { ... });
>
> and
>
> document.observe('dom:loaded', function() { ... });
>
> Currently I use the first one. Should I be changing to the second one
> for future proofing?
>
> Regards,
>
> Richard.
>
> --
> -----
> Richard Quadling
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to