PDA

View Full Version : Frame onLoad problems


cortic
10-06-2002, 08:21 AM
Ok, I have a two frames 'buttons' and 'page' - I have a script that runs from 'buttons' frame and references 'page' i.e. parent.page.function(); and it needs to run right after both frames have loaded, I tried putting the onLoad into the frameset tags but it seems to fire it before its loaded the frames... anyone have any suggestions? Have I missed something?

Thanks.

chrismiceli
10-06-2002, 03:44 PM
why don't you just put it on the page where the function is, it won't work on the frameset page b/c what you said, it isn't loaded yet. try and give us a little code please next time.

cortic
10-06-2002, 09:11 PM
Sorry, I'm not being clear.

////first the frameset:
<FRAMESET cols="95,*" border="5">
<FRAME SRC="buttons.html" name="buttons">
<FRAME SRC="page.html" name="page">
</FRAMESET>

////now the 'buttons.html' script
<body onLoad="double_check_count()">

function double_check_count()
{parent.page.at_what()}

function set_stuff(wha)
{//this just sets the menu to whatever 'wha' is (page reference)}

////now the 'page.html' stuff

//important bits are
<title>page one</title>
<script src="uni.js"></script>

////and lastly the uni.js stuff

function at_what()
{
var comp = new Array('page one','page two','page three'); kk=0;
while(document.getElementsByName('title').item(0)!=comp[kk])kk++
parent.buttons.set_stuff(kk)
}

tried this with many variations, without the source file, firing from 'page' onLoad from bottom of both frames, from bottom of source file, when navigating the site it works fine, that's because it starts at function at_what(); and is fired when 'page' is loaded, but when I hit refresh or the back button or the first time someone get onto the page (anything that would require both frames to load together) I need to fire double_check_count(); somewhere, and it needs both frames loaded to run.


I think I have a way to do it, I set an if statement in the first function that fires it when a variable gets to two, then have both frames fire body onLoad to this function, should run at the second hit, only one prob, don't know the syntax for if(parent.page.function()){determine whether that function is there, has loaded} - this returns an error.

Any input welcome.