Forum Moderators: open

Message Too Old, No Replies

Iframe controlled by links

iframe

         

free3yourmind

11:05 am on Apr 17, 2009 (gmt 0)

10+ Year Member



Does anyone knows how can i solve this problem:

I have 2 pages A and B, page B is a iframe page and no dont contain anything else. in page A i have 2 links one goes to google.com and the other to yahoo.com

How can i manage to open these links in the iframe. So if someone click on page A at the link "google" to direct him in the page B and open the link ( google.com ) in the iframe.

If someone else go to click on page A at the link "yahoo" to direct him in page B and open the link (yahoo.com ) in the iframe.

Is that possible? i have search everywhere and i couldnt find any answer.

Any help is much appreciated...

daveVk

12:46 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<iframe name="pageB"....

<a href="google.com" target="pageB">google</a>
<a href="yahoo.com" target="pageB">yahoo</a>

free3yourmind

10:30 am on Apr 24, 2009 (gmt 0)

10+ Year Member



if someone click on "google" it will open a new window with google.com, i dont want this...what i want is to open the page B in my website and display the link ( either google or yahoo )

daveVk

12:56 pm on Apr 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No if you set the target on the link to the name of the iframe as above, the page will open within the frame, cut the following and try it.

<iframe name="pageB" ></iframe>
<a href="http://google.com" target="pageB">google</a>
<a href="http://yahoo.com" target="pageB">yahoo</a>

This will not work for sites that contain frame busting code.

free3yourmind

1:13 pm on Apr 24, 2009 (gmt 0)

10+ Year Member



i tryied the above you sent me but it opens in the same page the links ( in the iframe ). What i want is by clicking the links ( google - yahoo) to move in ANOTHER page of my website and open the links in the iframe

daveVk

1:40 am on Apr 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



to move in ANOTHER page of my website and open the links in the iframe

So regardless of which link you press ( google or yahoo ) you wish to go a new page, say pageA.html. pageA.html is to contain an iframe sourced from the selected search engine ?

Use links something like
<a href="/pageA.html?search=google" >google</a>
<a href="/pageA.html?search=yahoo" >yahoo</a>

If you have php or other smart server use to set the iframe src according to "search". Else server will probably serve up pageA and javascript can set iframe src according to "search"

free3yourmind

7:27 am on Apr 25, 2009 (gmt 0)

10+ Year Member



thanks for your answer, i think is what i wanted. But how can i set iframe src to play according to "search" with javascript? any idea?

daveVk

11:31 am on Apr 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



function setFrame(){
var frame = document.getElementById( "pageB" );
if ( location.search.indexOf( "google" ) > -1 ) { frame.src = "http://google.com"; }
if ( location.search.indexOf( "yahoo" ) > -1 ) { frame.src = "http://yahoo.com"; }
}
window.onload=setFrame;

free3yourmind

2:35 pm on Apr 25, 2009 (gmt 0)

10+ Year Member



thanks a looooooooot!