Csaba said:
One approach is to have a variable at the top level which each loaded
frame increments (in its onLoad routine). When all frames have
loaded, then the variable's value will equal the number of i/frames
(which each onLoad routine is, of course, checking for. In that
event, the top.everybodyLoaded routine can kick off). The post below
illustrates this for the two i/frame case (the variant at the bottom
is closer to what I'm talking about here).
http://groups-beta.google.com/group/alt.html/msg/9971708cb459e632
Here's a concrete example that I put together on FF 1.0 / IE 6
that checks whether all the frames are loaded (but not for the
container page being loaded).
<html><head><title>Multiload Test</title>
<script type='text/javascript'>
loadCount = 0;
function everybodyLoaded() {
alert("Number of frames loaded: " +
window.frames.length); }
</script>
</head><body>
<iframe src="javascript:'<body onload="
alert(&#34;I\'m a/n &#34;+
window.frameElement.tagName);
if (++parent.loadCount==
parent.frames.length) parent.setTimeout(parent.
everybodyLoaded,0)">Frame 1</body>'">
</iframe>
<iframe src="javascript:'<body onload="
if (++parent.loadCount==
parent.frames.length) parent.setTimeout(parent.
everybodyLoaded,0)">Frame 2</body>'">
</iframe>
</body>
<html>
Also, it is (I think) instructive to see what happens
if you replace the two lines starting with 'alert' in
the main body (in other words, lines 10 and 11) with
the following 3 lines:
window.setTimeout(&#34;alert(
\\&#34;I\'m a/n \\&#34;+
window.frameElement.tagName)&#34;,0);
In this case, the alert does not hold up processing until
the onLoad of IFrame 1 has finished (by the alert being
responded to). Rather, that onLoad finishes along with
the others so that everybodyLoaded can run.
In IE6, the alert from everybodyLoaded (run from the onLoad
of IFrame 2) must be dismissed before the alert for IFrame 1
(pending from the setTimeout) will run.
However, in FF 1, both alerts will be shown, the IFrame 1
alert on top of the everybodyLoaded alert.
Csaba Gabor from Vienna