Forum Moderators: open

Message Too Old, No Replies

Nested frames

Change content in multiple frames from one hyperlink

         

smokeyb

10:19 am on May 20, 2003 (gmt 0)

10+ Year Member



Sorry to drag this up again, but can anyone help me make a link that loads my main and nested left frames, at the same time. I found an earlier explanation to this ( [webmasterworld.com...] ) but couldn't quite work out how to make "tedster's" advice work (if you see this tedster I appreciate the help.

BlobFisk

10:34 am on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, smokeyb!

Where are you running into difficulties in making that script work?

Tedsters script tells the parent (or container) frame to change the location of framename1 and framename 2 to the locations specified (pageA and pageB).

What you need to do is give each of your frames a unique name, replace framename1 and framename2 with the frames that you want to change. In your anchor, change pageA and pageB to the URL that you want.

Do you have multiple framesets? IE, does your left frame contain further nested frames?

smokeyb

12:35 pm on May 20, 2003 (gmt 0)

10+ Year Member



Hi BlobFisk, and thanks for the advice.
I am getting into unchartered territory with Java and consequently, I 'm getting lost. My needs are simple: I have 3 frames leftFrame, mainFrame and navFrame. I want to put a button (or whatever) in the navFrame that changes the other 2. Lets say that the pages I want to load are called "black2.htm" and "black2.htm", what would the script look like? And where do I get the button to point to? would it point to the Java? I am using Dreamweaver MX and I need to do this on all of the links in the navFrame. As a quick bit of background I need this because I want each catagory I use to have a sub catagory which loads in the leftFrame, but I want the page in the mainFrame to change to a catagory start page, rather than just cycling the navigation.

BlobFisk

1:39 pm on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First it's important to mention that Java and JavaScript are two completely different beasts. Java is a programming language, JavaScript is a web based scripting language.

So, I'm guessing that the 3 frames that you have mentioned are all part of one frameset, and using tedsters function from the post you mentioned above:


function doTwo(pageA,pageB)
{
(parent.leftFrame.location=pageA);
(parent.mainFrame.location=pageB);
}

We want to load black1.htm into the frame called leftFrame and we want to load black2.htm into the frame called mainFrame on one click (of a link in navFrame):


<a href="javascript:doTwo('black1.htm','black2.htm')">

The link is now running the function doTwo when the user clicks on it. The link is feeding two variables into the function (black1.htm and black2.htm), which (looking at the function), is changing the location of the frames.

Does this help?

smokeyb

5:15 pm on May 20, 2003 (gmt 0)

10+ Year Member



Thanks again BlobFisk,
I can see perfectly how it works now but.. (I must look like a complete idiot) where do I put the code? Do I put the first part in the navFrame and the rest, pointed to by the hyperlink? I presume I can then just alter the urls for each hyperlink for different catagories. Am I getting close or do I need a nanny?
Would be grateful for your help again... eternally.
Thanks
Smokey B

BlobFisk

5:30 pm on May 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey smokeyB,

All this code would go in the frame that contains the link, in this case navFrame.

So, between your <head> and </head> tags you would put:


<script type="text/javascript">
function doTwo(pageA,pageB) {
(parent.leftFrame.location=pageA);
(parent.mainFrame.location=pageB);
}
</script>

And in the html in your <a>nchor tags you would call the function as described above.

HTH

smokeyb

10:10 am on May 21, 2003 (gmt 0)

10+ Year Member



Thanks BlobFisk
Even an idiot like me can understand this now, I will put this advice to very good use indeed.
Smokey B