Forum Moderators: open

Message Too Old, No Replies

Linking to a frameset dynamically...

         

hapa_kevin

3:40 am on Jun 15, 2004 (gmt 0)

10+ Year Member



Ok, here is my problem... I hope I can explain it clearly. I have an index page that has a list of links to seperate websites. The index page is not framed and has a top nav. I also built a simple frameset, with the top frame for the nav, and the main body frame for the linked website. How, from the main index page, can I reference the frameset AND reference the selected website so it loads in the main frame?

Here's an example if it's confusing. Say the index page is about miter saws and has a list of links to companies that make them. When you click on a company link, the frameset opens with the nav in the top frame and the company website in the main frame.

I can do this all manually, I know, but that is a mucho pain. I am looking for a solution that is limited to javascript.

Help me! My brain exploded. Thanks.

Rambo Tribble

4:43 am on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I might first suggest that iframes are usually easier to work with than frameset documents, etc.

Secondly, frames or iframes are addressed through the parent-child relationship scheme. There is a top window with subframes denoted in array notation. As in:

top.frames[0]

It is legitimate to frame documents within frames, in which case notation like this can be appropriate:

top.frames[0].frames[3].frames[1]

Also, each subframe can address its immediate parent frame as parent. Siblings can access siblings through the parent. For instance, the second child frame of another frame (parent.frames[1]) can address its sibling, the first child of the parent with:

parent.frames[0]

This is distinct from how windows address each other, which is based on the opener, as opposed to parent, relationship.

All that said, the easiest way go about the whole thing is to use iframes, give each iframe an ID, then use document.getElementById() to change the src value of the target iframe.

hapa_kevin

7:47 pm on Jun 15, 2004 (gmt 0)

10+ Year Member



Thanks Rambo... working on that solution right now.