David Mark wrote:
> On Nov 19, 3:07 pm, Matt Kruse <m...@thekrusefamily.com> wrote:
>> On Nov 19, 1:06 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
>> wrote:
>> > <body onload="...">
>>
>> Script cannot add itself to this attribute, though.
>
> Groan. Script doesn't have to "add itself" to this attribute.
See below.
>> You're steering away from the real question, anyway.
>
> Yes.
No. I was just closing at it at a slower pace
>> Regardless of
>> whether you feel it should be used, is there any cross-browser way to
>> detect if window.onload has already fired?
>
> Of course. Attach a load listener (or use the standard onload
> attribute). They both do the same thing. One is proprietary and one
> is not.
But if we assume that, due to the flawed concept, there are only "lazy-
loaded" scripts, there is a chicken-and-the-egg problem with adding a load
listener with scripting. Hence my recommendation to use the `onload'
attribute of the `body' element in the first place.
> The proprietary window.onload property likely came about so that
> scripts in the HEAD could set a load listener to the BODY before the
> body is ready.
Unlikely: <http://docs.sun.com/source/816-6408-10/handlers.htm#1120545>
> Now, how to know if the BODY load event has fired? Set a flag, of
> course.
That is what I was aiming at. But some people apparently need it to be
spelt to them, so thank you for that.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee