Forum Moderators: open

Message Too Old, No Replies

Setting whole iframe target as parent?

         

cian

12:38 pm on Oct 1, 2005 (gmt 0)

10+ Year Member



Can anybody tell me how would I go about setting the target of an iFrame to "_top" or "_parent" (unsure which I'd need actually...).

My page consists of one file called "home.htm", which is a static html page. On this html page there is an iframe which links to another file on my web site called "stats.php", which is a big php file, and I'd rather not go near this.

The I frame is used to display "Latest gallery additions" from my gallery. The stats.php file generates the ten newest files from my gallery in a simple thumbnail format. Now, the problem is - when I click on one of the thumbnail pictures, it opens in the iframe. What I want it to do is have these links open in the "home.htm" page (which contains my iframe).

Now, let's assume I don't have access to the stats.php page the iframe is linking to (I do, but it's a big long complex php script which I really don't understand).

How do I set the target of the whole iframe itself, so that any links within simply open on the "top" page rather than within the iframe? I've tried simply adding a "target="_top"" onto the iframe tag, but obviously this doesen't work! I've done a lot of google searching, but I can't make head nor' tail of it all - all I can gather is I'll probably need some java script. My HTML knowledge is somewhat basic, but I know nothing regarding javascript.
Any help would be much appreciated, and if further clarification of what I'm blabbering about is required just ask.
Finally, my apologies for including a link in my previous post. I can understand why descriptions rather than links to an example are preferable, and I hope this post confines to your forum charter.
Thanks,
Cian

Bernard Marx

2:17 pm on Oct 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe you need the <base> element, which goes in the head.

Have a look in some HTML ref for more info (esp the href attribute), but I think this'll do it:

<base target="_top">

cian

2:28 pm on Oct 1, 2005 (gmt 0)

10+ Year Member



Hm, I just tried that using "_top", and no such luck.
I then set the base target to "_blank", and clicked a link outside the iframe, and it opened the new window, however it doesen't seem to include the iframe.
I don't think I can include this "base target" piece of code in the stats.php file as one - it doesen't have a head, or anything that looks remotely html like, and B - it's full of bits of code here there and everywhere...

Thanks for the help.

encyclo

12:33 am on Oct 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums cian!

Have you tried

target="_parent"
already? This may be a better choice for the links in the iframe document.

You will need to add this within the stats.php page, as it is this file which generates the HTML for the iframe. Without knowing how the document is written it is difficult to be very specific, but you will have to find where either the

head
section is created (for the
base target...
syntax as suggested above) or where the links are generated so you can add the
target
attribute to them.