Log in

View Full Version : iFrame Target: Linking from an external page.



web_junkie
06-03-2006, 02:51 AM
Hey Everyone.

I have been researching this for so long and can not find the solution to my problem:

This question involves 2 pages: "Page A" - the Home page and "Page B" - the Detail page.

Page B consists of three elements: (1) A Main iFrame (2) A Navigation iFrame, and (3) a Content iFrame.

I need to OPEN a link from the "News" iFrame on the Home page (Page A) INSIDE the CONTENT iFRAME of the Detail page (Page B).

I have searched High and Low and can not find where this is possible.

Please help as soon as possible.

Thanks in advance.

//web_junkie

web_junkie
06-03-2006, 04:29 AM
Not sure how long it takes to get a reply, but if anyone is home - please answer ASAP.

Thanks Again!

jscheuer1
06-03-2006, 04:53 AM
Missed this one the first time around. I hope that all your iframes have names. If not, make sure they each have a unique name, ex:


<iframe name="mainFrame" src="whatever.htm"></iframe>

Then from anywhere on the page or from anywhere on any of the pages in any of the iframes you should be able to do this:


<a href="someother.htm" target="mainFrame">Some Link</a>

And it will load into the frame with that name.

web_junkie
06-03-2006, 05:40 AM
Missed this one the first time around. I hope that all your iframes have names. If not, make sure they each have a unique name, ex:


<iframe name="mainFrame" src="whatever.htm"></iframe>

Then from anywhere on the page or from anywhere on any of the pages in any of the iframes you should be able to do this:


<a href="someother.htm" target="mainFrame">Some Link</a>

And it will load into the frame with that name.

Hi jscheuer1 - Naming the frames is the part I have working. I just cant get a link from a completely different page (PAGE A) to open a specific page in the content frame of (PAGE B)

I will post the actual work so that you can see what I am trying to accomplish:

http://www.somesite.com

The NEWS in the lower frame has to open the Wheels page with the specified manufacturer in the CONTENT FRAME. As if you clicked Wheels, then clicked Lowenhart.

Thanks Again for the prompt response JScheuer1 !!!!

djr33
06-03-2006, 06:07 AM
...it's working...
...?

jscheuer1
06-03-2006, 06:09 AM
None of your iframes have names.

web_junkie
06-03-2006, 10:00 PM
Thanks for the help guys! And Thank you for responding so quickly!


None of your iframes have names.

Sure they do, this is how the links know to open in the main content frame.


...it's working...
...?It works if you are on the same page. I am trying to get the link on the home page to open in the CONTENT FRAME of the Wheels page.

Is this even possible?

djr33
06-03-2006, 11:30 PM
I think the main issue here is that you want two actions to happen.

you can't click a link, get transfered to a new page, THEN have another link open, based on one click.

At least in html, that is.


If you can use php, you could do this:

Your link:

<a href="wheels.php?iframe=page.ext"

On your wheels page, here is (part of) the iframe tag:

<iframe ..... src="<?php echo $_GET['iframe']; ?>">

That will set the iframe's src to "page.ext"

Note that the wheels page MUST be a php page, ie, have a .php extension and you need php installed on your server.
The first page just uses a normal link, but with ?variable=value at the end, so that can just be html. And the page included in the iframe can be html as well. (they could both be php as well, won't matter)


there are similar ways to use that type of link with javascript, and maybe other ways, but I don't know them.


Is this what you're wanting?

jscheuer1
06-03-2006, 11:48 PM
Thanks for the help guys! And Thank you for responding so quickly!

Quote:
Originally Posted by jscheuer1
None of your iframes have names.

Sure they do, this is how the links know to open in the main content frame.

It works if you are on the same page. I am trying to get the link on the home page to open in the CONTENT FRAME of the Wheels page.

Is this even possible?


From your source of the link (http://www.optiquemedia.com/Dev/D2A/) you supplied:


<iframe src="news.html" frameborder="0" scrolling="auto" width="238" height="100" title="Ades News"> News </iframe>
<iframe src="specials.html" frameborder="0" scrolling="auto" width="238" height="100" title="Specials"></iframe>
<iframe src="feat_prod.html" frameborder="0" scrolling="auto" width="238" height="100" title="Featured Product"></iframe>

Only three iframes, no names.

djr33
06-04-2006, 12:12 AM
John, looks like the iframes on (only) the wheels page are named.

web junkie, you really should just get in the habit of naming all the frames, though... it'll come in handy.... no need to fix later.

web_junkie
06-04-2006, 01:20 AM
Thank you - You guys are the best.


From your source of the link you supplied:


<iframe src="news.html" frameborder="0" scrolling="auto" width="238" height="100" title="Ades News"> News </iframe>
<iframe src="specials.html" frameborder="0" scrolling="auto" width="238" height="100" title="Specials"></iframe>
<iframe src="feat_prod.html" frameborder="0" scrolling="auto" width="238" height="100" title="Featured Product"></iframe>

Only three iframes, no names.

Yeah, only the Wheels page has the frames names, but I will get into the habit of naming all frames. ;)


I think the main issue here is that you want two actions to happen.

you can't click a link, get transfered to a new page, THEN have another link open, based on one click.

At least in html, that is.


If you can use php, you could do this:

Your link:
<a href="wheels.php?iframe=page.ext"

On your wheels page, here is (part of) the iframe tag:
<iframe ..... src="<?php echo $_GET['iframe']; ?>">

That will set the iframe's src to "page.ext"

Note that the wheels page MUST be a php page, ie, have a .php extension and you need php installed on your server.
The first page just uses a normal link, but with ?variable=value at the end, so that can just be html. And the page included in the iframe can be html as well. (they could both be php as well, won't matter)


there are similar ways to use that type of link with javascript, and maybe other ways, but I don't know them.


Is this what you're wanting?

This is EXACTLY what I want. Unfortunately, I am primarily a Motion Graphics Artists and never took the time to learn PHP. Looks Like I may have to :).

djr33
06-04-2006, 07:05 AM
The php above is REALLY simple.

You just need to have php enabled/installed on your server, and rename your page with the .php extension.

Then get a BASIC understanding of how php works:
1. It is serverside... totally hidden from the viewer.
2. It treats normal text on the page as html, will work EXACTLY like it did before.
3. Anything in <?php .... ?> things will be interpreted by the server, and sent to the browser as html.

So... just take <?php echo $_GET['iframe']; ?> and put where you want that value to show up.

The GET thing is basically just that... refers to stuff in the address bar. It's as simple as it seems.
It's usually used in forms (<form method="get">) where it sends the data along like that, but it can also be used as a "url". Nice trick for sending data.
echo just means, basically, display.
So... display the value of "iframe".

web_junkie
06-04-2006, 03:14 PM
The php above is REALLY simple.

You just need to have php enabled/installed on your server, and rename your page with the .php extension.

Then get a BASIC understanding of how php works:
1. It is serverside... totally hidden from the viewer.
2. It treats normal text on the page as html, will work EXACTLY like it did before.
3. Anything in <?php .... ?> things will be interpreted by the server, and sent to the browser as html.

So... just take <?php echo $_GET['iframe']; ?> and put where you want that value to show up.

The GET thing is basically just that... refers to stuff in the address bar. It's as simple as it seems.
It's usually used in forms (<form method="get">) where it sends the data along like that, but it can also be used as a "url". Nice trick for sending data.
echo just means, basically, display.
So... display the value of "iframe".

THANK YOU! That doesn't look very hard at all. So echo works the same way it does in DOS or in batch files. I should have this down in a week - the basics that is.

One more question: Can PHP pages exist on the server with HTML pages. I would like to gradually make the transition or only edit the pages that are needed instead of changing 1500 pages.

//web_junkie

djr33
06-04-2006, 09:32 PM
Any page that you want to be parsed as php much be of the extension .php.
So... yeah, sure, you can have other html pages up. No problem there.
The ONLY page that needs to be php is one with code on it. It can use includes (basically taking the contents of one page and putting it on another), frames, whatever with html or other pages.

Also, remember.... just change the extensions of your .htm pages to .php and they'll still work just fine. consistancy is nice, if only for ease of use. However, remember to change all links to them too. So... feel free to leave them as .htm if you don't feel like changing them all.

cedric
05-22-2007, 05:52 PM
Not sure if this thread's still open, but I did enjoy the code! Worked great for me.

Because I use an iframe on the very front page, I would like to specify a default page to load if none is specified via ?iframe=page.html Being a bit of a newcomer to php, I hope you can help.

I'm thinking some sort of if, else, statement, but I've tried and nothing works!

TIA,

Cedric

djr33
05-22-2007, 06:07 PM
<?php
if (!isset($_GET['iframe']) {
$iframe = 'default.htm';
}
else {
$iframe = $_GET['iframe'];
}
?>


Or, for a shorter but more complex code--
echo ($_GET['iframe'] ? isset($_GET['iframe'] : 'default.htm');

cedric
05-22-2007, 07:39 PM
<html>
...etc...
<body>
<iframe src="
<?php echo ($_GET['iframe'] ? isset($_GET['iframe'] : 'home.html'); ?>

"allowtransparency="true" name="Content" scrolling="auto" frameborder="0" height="760" width="100&#37;">

</iframe>

</body>
</html>


This is what I put in - doesn't work properly, in fact the page doesn't even load when this string is put in there. I tried the other one too, same effect. It does load, minus the iframe source "home.html" when I just use
<?php echo $_GET['iframe']; ?>

cedric
05-23-2007, 01:56 AM
<!--iframe start-->
<?php
if (!isset($_GET['target'])) {$target = "home.html"; }
else {$target = $_GET['target'];}
?>

<td width="79%" align="center" valign="middle">
<center>
<iframe src="<?php print $target; ?>" allowtransparency="true" name="Content" scrolling="auto" frameborder="0" height="760" width="100%">
</iframe>
</center>
</td>

<!--iframe end-->

cedric
05-23-2007, 02:00 AM
Main Page: (defaulted to home.html)
http://www.behemoth.ca

or Cities & Scenery Gallery:
http://www.behemoth.ca?target=cities_scenery

or People & Objects Gallery:
http://www.behemoth.ca?target=people_objects

djr33
05-23-2007, 02:22 AM
Ah, glad it worked. I might have had a bug in the code, but I'd need to play with it a bit to check. Working now, so that's good.

zilian77
09-17-2007, 10:11 PM
Hi, i hope this thread is still open..... i followed everything stated, how to get from one page to another's iFrame, made the page with the iFrame a .php and put the code


src="<?php echo $_GET['iframe']; ?>"

into the iframe and did the link on page 1:


<a href="flash.php?iframe=page.ext"

what i needed was to go from page 1 to the flash.php......:

the link inside the flash.php page i need is rather long...:
adctn/flash_video/on-demand/culto299_300k/culto299_300k.html

any help would be much appreciated!!!!

zilian77
09-17-2007, 10:54 PM
NEVER MIND.....

I was doing something wrong now i corrected it .... thanxs anyways!

gus
01-12-2010, 08:19 PM
I think this is the same query as the one above, but just to be sure, I 'll ask it in my own way:

Can specific iFrame content appearing in its host page can be summoned from another page?

In other words, suppose that page1.html contains an iFrame photo gallery. When you visit page1.html, the default photo in the iFrame is photo#1, but this can be changed dynamically by clicking links elsewhere on the same page.

I'm a visitor at page2.html, but I need a link that will take me directly to page1.html, photo #8. Can this be done with a single URL that will not simply open page1.html at photo #1 and require another click for the required photo?

My iFrame is just about as stock as they get ... no javascript ... yet. I imagine that the solution will be to use a js of some sort, but I'll wait to hear what you experts offer before I jump into this minor problem with both feet.

Thanks sincerely if you can help.

jscheuer1
01-13-2010, 08:20 AM
HTML alone cannot do this. There are javascript approaches to this. However, the solution put forth (by djr33) as regards this in this thread (see post number 8 (http://www.dynamicdrive.com/forums/showpost.php?p=38589&postcount=8)) uses PHP, a server side language, which if it is available to you on your host is better and simpler than javascript for this purpose.

If you want a javascript solution, ask in the javascript forum.