Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML HTML Basics

Help... Using a link to open a new window an iframe...

Discussing Html . Code , Software , other

Moderators: macek, egami, gesf

Help... Using a link to open a new window an iframe...

Postby Gumbootboy » Fri Jul 02, 2004 5:34 am

Hi, Here is what i would like to do...

I would like to have a link and when it is clicked it loads a new page, the new page has an iframe in it and the content of it is determined by which link is clicked.

i.e. I have three links, all loading the same page but the content in the iframe changes depending on the link.

Is this possible?

:help: By The Way, im quite new to html, i dont know if this is possibly but if it is and someone can explain it to me, i'd be very thankful, especially if i can understand it. Thanks

Gumbootboy
Gumbootboy
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Jul 02, 2004 5:20 am

Postby swirlee » Fri Jul 02, 2004 6:48 am

You can't do this with HTML alone, but you could do it with PHP.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Re: Help... Using a link to open a new window an iframe...

Postby WiZARD » Sat Jul 03, 2004 1:43 am

If you want to open new window in link (<A HREF...) need set TARGET....
Example:
<A HREF="http://www.google.com" target="_blank">Google</A>
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Re: Help... Using a link to open a new window an iframe...

Postby Gumbootboy » Sat Jul 03, 2004 2:56 am

WiZARD wrote:If you want to open new window in link (<A HREF...) need set TARGET....
Example:
<A HREF="http://www.google.com" target="_blank">Google</A>


Yeah, i kindof know that part, i was wondering if i can chose the content of an iframe on the page using the link. using your google example... something like:

<A HREF="http://www.google.com" target="_blank" iframesrc="1.html">Google 1</a>

<A HREF="http://www.google.com" target="_blank" iframesrc="2.html">Google 2</a>

<A HREF="http://www.google.com" target="_blank" iframesrc="3.html">Google 3</a>

Each link would open the same web page but the iframe content changes depending on the link.
Gumbootboy
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Jul 02, 2004 5:20 am

Postby ruturajv » Sun Jul 04, 2004 8:15 pm

there I'm posting this for the 3rd time :D

Code: Select all
<iframe src="default.php" id="idname">
</iframe>
<script type="text/javascript">
function changeurl(url)
{
   d = document.getElementById("idname");
    d.src = url;
}
</script>

<a href="javascript: changeurl('someurl')">Change url</a>
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby Gumbootboy » Tue Jul 06, 2004 6:53 am

Hi, ruturajv

Can you explain, how this does what i want? I can see how if you change 'someurl' to the url of the page you want in the irame then click the link it changes the content but this inst what i rellay wanted.

This is what i was planning to use it for...

I have a web page with a list of songs from multiple albums and links to the lyrics of each song. I also have a web page for each album with an iframe, on each of albums web page there is a link of each song on the album. When you click the link the iframe content changes to the song lyrics. Going back to my web page with all the songs on it, when you click a link on this page i want it to take you to the specific albums web page and have the content of the iframe be the lyrics of the song clicked.

If the code you showed me actually does this can you explain how?

Thanks
Gumbootboy
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Jul 02, 2004 5:20 am

Postby ruturajv » Thu Jul 08, 2004 8:26 am

keep the iframe in a place where there is a major space... main content area

and put the navigation links...
in the navigation links, use the links using javascript to change the source of your (song page | title | album ) or what ever you want..
:-D
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

DONE!

Postby Gumbootboy » Wed Jul 14, 2004 11:14 pm

:-D
Hi, thanks for your help everyone althought i did not understand it, lol. I noticed this topic had quite a few views so i thought i would post how i did what i was attempting.

1) In the page of links that i had i used this code:

<a href="album.html?song1.txt">

NOTE:
album.html is the page containg the iframe
song1.txt is the content i wanted in the iframe

2) In the page with the iframe (for me album.html) you put this code in
the head tags:

<script language="JavaScript"><!--
var newURL = unescape(location.search.substring(1));
//--></script>

3) Enter one of these onload codes on the page with the iframe (only one, i.e if you already have a body onload you can use the iframe onload instead):

<iframe onload="parent.ZZZZZZZZZZ.location.href=newURL;" name="ZZZZZZZZZZ"></iframe>

OR

<body onload="if (newURL != '') parent.ZZZZZZZZZZ.location.href = newURL ">

NOTE: 'ZZZZZZZZZZ' is the iframe name

ALSO note if this doesnt work offline you may want to upload it and see if it works, althought it worked for me offline.

All of this information was found at:
http://www.programmingtalk.com/showthre ... ge=2&pp=10
(Posted by: KingSky)

Thanks very much everyone!
Gumbootboy
Gumbootboy
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Jul 02, 2004 5:20 am


Return to HTML Basics

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.