Forum Moderators: open

Message Too Old, No Replies

Frames loading traffic jam

Code for child frame loading sequence

         

Adam5000

5:36 pm on Mar 31, 2006 (gmt 0)

10+ Year Member



I've got a parent frame page with two child frames on it and below is the code I'm using.

<html>
<head>
<title>Parent frame page</title>
</head>
<frameset cols="100%,*">
<frame src="Universal_Home_page.htm" name="fr_home"/>
<frame src="Universal_sound_page.htm" name="fr_sound"/>
</frameset>
</html>

On the sound page I've got

<body onload="parent.fr_home.startAnnimation()">

The parent.fr_home.startAnnimation() command on the sound page works great. It starts the annimation after both pages have loaded and that's what I want.

The problem is, while the pages are loading it's a traffic jam with both pages trying to load first. Is there a way to specify the loading order with the home page loading first.

Fotiman

6:51 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't believe there's any way to tell the browser to load 1 frame first, then the other. However, you could do something like this to ensure that some JavaScript action doesn't take place until your page finishes loading.


// This code goes in the parent frameset
var loadedFrames = new Array();
function frameLoaded( idref )
{
loadedFrames[loadedFrames.length] = idref;
}


function isFrameLoaded( idref )
{
for( var i = 0; i < loadedFrames.length; i++ )
{
if( loadedFrames[i] == idref ) return true;
}
return false;
}

Then on your "home" frame, you would do:
body onload="parent.frameLoaded('fr_home');"

And on your animation page, you would have some polling function that called parent.isFrameLoaded('fr_home') until it returned true, at which point you would then know the home frame was loaded. Probably using setTimeout() or setInterval().

Hope that helps.