Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variables and frames

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi,
i have done advanced code in javascript, but it was always on the same page. I'd like to know if it's possible for example to do this :

have 2 frames, let's say frameA and frameB. I declare an array (or an other variable type )into frameA and want to add values into this array from frameB, so that when frameB is reseted, the array is still alive in frameA with all the values.
Is it doable ? how can i access to a variable on an other frame ? what is the syntax ?

thanks Best regards,
Elise, XML learning girl X-)
 
i ask this because i tryed this :
Code:
<FRAMESET COLS=&quot;5%,95%&quot;>
<FRAME NAME=&quot;left&quot; SRC=&quot;testleft.html&quot;>
<FRAME NAME=&quot;main&quot; SRC=&quot;testmain.html&quot;>
</FRAMESET>
</HTML>

********testleft.html*********
<html>
<SCRIPT event=onload for=window language=javascript>
var toto=&quot;tata&quot;;
</script>
<body>

</body>
</html>

********testmain.html*********
<html>
<SCRIPT event=onload for=window language=javascript>
alert(parent.left.toto);
</script>
<body>

</body>
</html>

and i get an undefined error !!
Best regards,
Elise, XML learning girl X-)
 
Looks like to me that SHOULD work, except that maybe when the alert executes the left frame hasn't finished loading yet. I gave an example of what you want to do in Thread452-164717.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
A question and an answer I have.

the &quot;event=onload for=window&quot; portion in the header of your scripts, can you explain it please?

When I removed them from your &quot;testleft.htm&quot;, it was able to reference the variable correctly.

So I muse:

event=onload : script does not execute till document is loaded?

and

for=window : apparently restricts the contents of said script to that frame only?

Also, just to make doubly shure that the var toto is populated, I enclosed the alert in &quot;testmain.html&quot; in a one second timeout.

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top