Forum Moderators: open

Message Too Old, No Replies

Frames. Parent calling function in child frame

Code for parent calling function in child frame

         

Adam5000

10:13 pm on Mar 29, 2006 (gmt 0)

10+ Year Member



I’m using background sound on my pages. And to make the music play continuously without restarting when a viewer goes to a new page I’m using frames. Below is the code for the parent frame page. I put the home page in frame one at 100% and the sound page (with only music) in frame 2 at 0%. The home page contains annimation and the idea is to have the annimation going with music playing in the background. And thanks to help I received here, the loading sequence is correct now. The sound page waits for the home page to load. The home page loads and then the sound page loads after that which is just right.

The problem is, the code that calls the function that starts the annimation "startAnnimation()" is on the home page linked to the onload event (onload="startAnnimation()") and the annimation is started after the home page loads but before the sound page loads.

Is there a way to tell the parent page, after both (all) pages are loaded (home page first), to call the function (located on the home page) that starts the annimation.

<html>
<head>
<title>Frames Parent</title>

<script language=javascript>
function loadSound()
{fr_sound.location.replace('Universal_sound.htm');}
</script>
</head>

<frameset cols="100%,*" onload="loadSound(); return true;">
<frame src="Universal_Home_page.htm" name="fr_home"/>
<frame src="Universal_sound.html" name="fr_sound"/>
</frameset>
</html>

Help!

DrDoc

10:29 pm on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



in your Universal_sound.html page ...

<body onload="parent.fr_home.StartAnimation();">

Adam5000

9:04 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



That works fabulous Dr. I put the code in the sound page in the body element and it worked just right. I took out the code on the home page that called the function that starts the annimation and put it on the sound page in the body element and it works just right. I've got one last small issue and the site will be working good and I can give it a rest for a while.

When I added to the sound page, the code that called the function for the annimation, to get it to work I had to remove the javascript function that specified the loading sequence. But for some reason the loading sequence is still in order. The home page loads first and the sound page loads second. Which is what I want but I don't understand why it still works. I removed the function that put the loading sequence in order in the first place. My guess is, by default, the child page that's listed first is loaded first.

And my question is, is there a definite way to specify the loading sequence rather than rely on the default (child page that's listed first is loaded first. If that's what's going on)?