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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a variable to a child frame

Status
Not open for further replies.

Ramjet

Programmer
Nov 1, 2000
21
US
Hello,

I have a nested frames page where the variable gets passed all the way to the highest level just fine but then I want to pass it down a different branch and I can't quite get it.

I have tried many different combinations of the following
with no luck:

HlpLoc is the variable being passed up and it does arrive just fine. PassOn is a function in a child window. (Frame#1 header / appheader.html) The variable never arrives because the code below is faulty somehow

<script language=&quot;javascript&quot;>
var HlpLoc = &quot;&quot;
function PassLoc(HlpLoc)
{
self.header.PassOn(HlpLoc)
}
</script>
</head>

<frameset rows=&quot;100,*&quot; border=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>

<frame name=&quot;header&quot; src=&quot;appheader.html&quot; scrolling=&quot;no&quot; noresize frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>
<frame name=&quot;body&quot; src=&quot;appfrmbod.html&quot; scrolling=&quot;no&quot; noresize frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>

</frameset>

Any input or the proper way to pass variable down would be appreciated.
 
how do you call the function ? where from ?
what error are you getting ?
 
OK I am working with 2 frame branches.
Left and right. The right frame branch performs
a calculation and that result is put into a variable.
The variable is then passed to the parent window
with the line parent.parent.MyFuncName(MyVar).
The frame is two layers down so I use
parent.parent to get to the very top window then
MyFuncName is a function in that parent window that
accepts this variable and for now writes it out
as an alert msg so I can see that it has correctly arrived.

Now can I pass this same variable down to a frame on the left branch using a similiar method?

I am doing it this way because my understanding is that
child frames can't talk to each other without going through the parent? If there is a better way to communicate between frames please tell me where to read up on it.

The frames are all named and I have tried many combinations like self.frame[0].MyFunc(MyVar) but it doesn't work?

The full code for what I am trying to pass down is in my first post.
 
ok, supposing the frame on the left is name ramjetframe, you can probably use:

parent.ramjetframe.whatever to access it.

jared@aauser.com
 
sometimes top works better than parent
top.main_frame.left_frame.function
 
OK For anyone who cares to know I figured it out Here is how to make it work.

Put this code in the frame on the right side of your frame branch.

<input type=&quot;radio&quot; name=&quot;NewPol&quot; value=&quot;NewPol.html&quot; onfocus=&quot;parent.parent.frames['header'].PassOn(this.value)&quot;>

the first should be straight forward. parent.parent takes me to the top level of my frames but you can add as many .parent as needed to get to the top of yours.
frames.['header'] resolve to the frame I have named &quot;header&quot; in the TOP PARENT window. The frame src=&quot;...&quot;
is resolved from the frame tag with name=&quot;header&quot; and the PassON function is located on that new page. I then dump the variable to a new function called RLoad. I know the variable arrives because using alert() it displays
the variable value.

function RLoad(HlpLoc)

{
location.href = &quot; + HlpLoc;
location.reload
}

This function works in Netscape 4.x and 6.0 but it doesn't work in IE 5.0 or 5.5. A different variation works in IE 5.5
but nothing I have tried works in 5.0.

So if you would like please check out my new thread to try and solve this problem otherwise thatnks for the help all the input actually helped me put everything together.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top