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

Using button in Frame1 to control Frame2

Status
Not open for further replies.

tomhughes

Vendor
Joined
Aug 8, 2001
Messages
233
Location
US
Does anyone know how to control one frame from another frame? I am trying something simple, and probably have made some simple mistake, But I am trying to use a button to control one frame from another frame. I have two frames in a frameset. The top frame name is "topFrame" and its soucre is Page1.htm. The bottom frame name is "bottomFrame" and its source is Page2.htm. The button is in Frame2.


Home1.htm contains the frameset and contains:

<frameset col rows=&quot;*,*&quot;&quot;50%,*&quot;>
<frame src=&quot;Page1.htm&quot; name=&quot;topFrame&quot;>
<frame src=&quot;Page2.htm&quot; name=&quot;bottomFrame&quot;>
</frameset><noframes></noframes>



Frame1.htm contains the code below and is in the body of the page

<script language=&quot;JavaScript&quot;>
function Refresh() {
alert('Hello world');
}
</script>


Frame2.htm contains the button

To the button in Frame2 I have attached a Javascript behavior &quot;call Refresh()&quot;
I have set the Link in the properties of the button to &quot;Home1.htm&quot; which is the
name of my Frameset, and the target to &quot;_top&quot;.

When I press the button I can see the frames flicker, but I don't get any alert window.
Do I have to tell Page1.htm to get the focus, or some similar command ???
 
parent.top.frames[index].property

is your syntax...

so, if you had a function:

function showAlert(){
alert('hello world');
}

in the second frame, then you could call it from the first by saying:

parent.top.frames[1].showAlert();

where 0 is your first frame and 1 is your second.
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top