From: David Mark on
On Nov 19, 3:07 pm, Matt Kruse <m...(a)thekrusefamily.com> wrote:
> On Nov 19, 1:06 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
> wrote:
>
> >   <body onload="...">
>
> Script cannot add itself to this attribute, though.

Groan. Script doesn't have to "add itself" to this attribute.

>
> You're steering away from the real question, anyway.

Yes.

> 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.

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.

Now, how to know if the BODY load event has fired? Set a flag, of
course.
From: David Mark on
On Nov 19, 12:55 pm, Matt Kruse <m...(a)thekrusefamily.com> wrote:

[...]

>
> If a script is lazy loaded and needs the DOM to be ready, it can
> attach to the window's load event. But if that has already fired, then
> the script's code will never run. Alternatively, it can just fire its
> code inline, but the DOM may not be ready.
>

And what sort of scheme are they working on where their scripts are
unclear about whether the load event has fired? Sounds like a recipe
for disaster to me.

<body onload="loaded = true;">

Or, as mentioned, set window.onload if you think that is a cooler,
more "unobtrusive" solution (despite the inherent drawbacks).
From: Thomas 'PointedEars' Lahn on
David Mark wrote:

> On Nov 19, 3:07 pm, Matt Kruse <m...(a)thekrusefamily.com> wrote:
>> On Nov 19, 1:06 pm, Thomas 'PointedEars' Lahn <PointedE...(a)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
From: David Mark on
On Nov 19, 5:34 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> David Mark wrote:
> > On Nov 19, 3:07 pm, Matt Kruse <m...(a)thekrusefamily.com> wrote:
> >> On Nov 19, 1:06 pm, Thomas 'PointedEars' Lahn <PointedE...(a)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 :)

I figured. I'd just as soon be done with the discussion.

>
> >> 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.

Right. The whole question is silly.

>
> > 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>

I don't follow.
From: Jorge on
On Nov 19, 11:34 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
>
> Unlikely: <http://docs.sun.com/source/816-6408-10/handlers.htm#1120545>

If you specify an onLoad event handler for an Image object that
displays a looping GIF animation (multi-image GIF), each loop of the
animation triggers the onLoad event, and the event handler executes
once for each loop.

Is this true ?
--
Jorge.