Hi, I'd actually like to see Prototype handle this edge case for you, but as far as I know it doesn't.
There's an *undocumented* way you can check: The `document.loaded` property. But that's undocumented and so subject to change from dot release to dot release. (Not necessarily a big problem, it just means you have to test it when you upgrade from [say] 1.6.1 to 1.6.1.1 or 1.6.2 or 1.7.0.) So: function callWhenDOMReady(f) { if (document.loaded) { f.defer(); } else { document.observe("dom:loaded", f); } } Note that that calls the callback asynchronously (via Function#defer), *not* inline, when the DOM is already loaded -- because the call would be asynchronous if the DOM weren't loaded, so doing it that way in all cases avoids any issues where the calling code assumes the call won't have happened yet. FWIW, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Mar 23, 4:40 pm, John <jth...@midwestern.edu> wrote: > I am using > > document.observe("dom:loaded", function() { > ... > > }); > > to hook into the dom loaded event, but I'm finding that if the dom > loaded event has already fired my code is not executed. So I want to > test if the dom is already loaded so I know whether it immediately > execute or add this observe event. Is there a way to test if the dom > is already loaded? > > Thanks. -- 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 prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.