• 0

Targetting multiple iframes with one link


Question

Hi folks..

Having a little trouble with a site im working on at the moment,

On the main html page i have a series of links. Also on the main page i have 2 iframes. What i want to happen is that when one of these links is clicked a different page will appear in each iframe.

I'm assuming I can either do this straight from the link or by using some JScript as one of the pages is loading, but i cant for the life of me figure it out.

Any help would be great.

--WeeJames

3 answers to this question

Recommended Posts

  • 0

Hello, doing somthing like this might work:

With javascript multiple targets are possible.

Here's a simple case, with just two target iframes names numberOneiframe and numberTwoiframe:

function doTwo(pageA,pageB) 
{ 
(numberOneiframe.location=pageA); 
(numberTwoiframe.location=pageB); 
}

And the script for the link:

<a href="javascript:doTwo('page1.html','page2.html')">Change Two iframes</a>

That one link should load page1.html into numberOneiframe and load page2.html into numberTwoiframe.

  • 0

i think the code you'll want for it to work in all browsers is:

iframe code:

<iframe name="iframe1" src="..." id="iframe1"></iframe>

js code:

function iFrame_src(url) {

frames['iframe1'].location.href = url;

}

link code:

<a href="java script:iFrame_src('another_page.html');">

obviosly this can work with multiple frames of different names

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.