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!

Change one frame as the user navigates in the other

Status
Not open for further replies.

RobBroekhuis

Technical User
Oct 15, 2001
1,971
US
I'm sure this is done all the time, but I didn't manage to find a good example: I have two frames - one frame is for navigating through a set of static html pages. The other one contains a server-side scripted page, where notes about the static page are displayed (and can be updated). I'd like the second frame to change when the user navigates to a different page in the first frame. Since the content of the first frame is fixed and static html, any javascript would have to reside in the frameset page or in the scripted page of the second frame. Can this be done?

Rob
[flowerface]
 
Yeah - I can do the location switching. My challenge is to use events to decide WHEN the location needs to be switched. So far, I've klutzed it together with 1-second timeouts, looking at the href of the navigation frame every second and adjusting the other frame as needed. But I was hoping there's something better...

Rob
[flowerface]
 
Why not use the onload event for the content pages? If I understand what you're saying it goes like this:

1. When a page loads up in the content frame, you want to have a description in the notes frame.

2. When navigating to a new page in the content frame, you need to change the description in the notes frame.

If this is the situation then you just need to do something like this in each of the content pages:
Code:
<script type="text/javascript">
var notes = "someNotesAboutThisPage.html"
function onloadFunction() {
   top.frames['noteFrame'].location = notes;
}
window.onload = onloadFunction;
</script>

The only problem with this solution is when you would navigate to a page that does not have a corresponding note to go with it, then the notes from the last page would still appear.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
When the url of the page in the second frame changes (because the user navigates to a different page there).

Rob
[flowerface]
 
Kaht, the content pages aren't mine to change - so I need to work with the first frame or the container.

Rob
[flowerface]
 
Then you're pretty much stuck with the timeout solution. I don't think that there is an onchange event for frames. You'll just have to continually check to manually see if it changes [sad]

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
you can try adding code to your frameset page. something like:

Code:
var myF1 = window.frames['myFirstFrame'];
var myF2 = window.frames['mySecondFrame'];

and then:

myF2.onload = function() { myF1.location = 'blahblahblah'; };



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Hi again,
I tried the frame.onload construct, and couldn't get it to work (IE6). I'll play around some more - thanks for the help!


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top