How to control launch of frames

D

Don

I have a site where significant intercommunication occurs between three frames. On startup it's
important that frame "A" be loaded and fully executed before frame "B" is loaded, as "B" will test
some "A" variables. I've tried just listing the frames in the frameset in the order I want them
loaded. But, that didn't seem to guarantee which would be loaded and fully executed first,
especially if there is a significant difference in the amount of JS code in each frame. I found a
later listed frame was loaded and already testing a variable of an earlier listed frame. How does
one control this?

Thanks for your help.
Don
 
N

Nico Schuyt

Don said:
I have a site where significant intercommunication occurs between
three frames. On startup it's important that frame "A" be loaded and
fully executed before frame "B" is loaded, as "B" will test some "A"
variables. I've tried just listing the frames in the frameset in the
order I want them loaded. But, that didn't seem to guarantee which
would be loaded and fully executed first, especially if there is a
significant difference in the amount of JS code in each frame. I
found a later listed frame was loaded and already testing a variable
of an earlier listed frame. How does one control this?

I don't think you can access the variables defined in frame A in another
frame (only the ones defined in the frameset)
Make it easier to replace the frames by div-boxes. To include the menu on
every page a snippet of PHP will do the trick: <? include "menu.htm"; ?>
 
S

SpaceGirl

Don said:
I have a site where significant intercommunication occurs between three frames. On startup it's
important that frame "A" be loaded and fully executed before frame "B" is loaded, as "B" will test
some "A" variables. I've tried just listing the frames in the frameset in the order I want them
loaded. But, that didn't seem to guarantee which would be loaded and fully executed first,
especially if there is a significant difference in the amount of JS code in each frame. I found a
later listed frame was loaded and already testing a variable of an earlier listed frame. How does
one control this?

Thanks for your help.
Don

You're using the wrong technology. Cross-frame scripting is a mess, and
there is NO way to have something load before something else on a web
page.

You need to rethink this - do it all server side in ASP or PHP. Never
rely on scripting at the front end as the user may have it turned off.
You can still use frames, but generate your frame contents (or the
frameset itself) at the server.

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
T

Toby Inkster

Don said:
I have a site where significant intercommunication occurs between three
frames. On startup it's important that frame "A" be loaded and fully
executed before frame "B" is loaded, as "B" will test some "A" variables.

Firstly, please fix your line wrapping. 100 characters is not an
appropriate place to wrap. 70 to 76 characters would be better.

Secondly, in answer to your question, the only way to control the
loading order for the frames would be to use a server-side script to
delay sending the files in the first place.

As an example... instead of:

<frameset cols="*,*,*">
<frame name="a" src="a.html">
<frame name="b" src="b.html">
<frame name="c" src="c.html">
</frameset>

Use:

<frameset cols="*,*,*">
<frame name="a" src="waiter.php?file=a.html&amp;sec=0">
<frame name="b" src="waiter.php?file=b.html&amp;sec=3">
<frame name="c" src="waiter.php?file=c.html&amp;sec=6">
</frameset>

Where waiter.php does this (roughly):

<?php
$sec = $_GET['sec'];
$file = $_GET['file'];
if (!(strpos($file,'..')===FALSE)) {
echo "no directory climbing allowed";
exit;
}
if (!preg_match('/^[0-9]*$/',$sec)) {
echo "sec must be a number";
exit;
}
if ($sec>20) {
// upper limit
$sec = 20;
}
sleep($sec);
include($file);
?>
 
D

Don

Thanks for your replies everyone. You've definitely given me something to
think about. Sounds like I need to consider moving much of this to the
server.

Actually, yesterday afternoon I figured out how to do it using handshaking
flags in a stateframe. But, as you pointed out, it probably would be better
all around to just do this on the server. I'll look into that.

Thanks much,
Don
 
C

Csaba Gabor

If you want mainCode in Frame A to run AFTER Frame B has
loaded, you could have something like (untested):

Frame A:
<body onload="if (top.BisHere) mainCode(); else top.AisHere=true;">

Frame B:
<body onload="if (top.AisHere) top.frames['A'].mainCode(); else top.BisHere=true;">


And if that works, you could probably replace BOTH
top.AisHere and top.BisHere with just top.isLoaded
and have identical onload attributes in both frames:
onload="if (top.isLoaded) top.frames['A'].mainCode(); else top.isLoaded=true;"

Csaba Gabor from Vienna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top