Topic: Links target to iframe, but open in a new tab

Hello again,

I've been having a problem with my hyperlinks targeted to iframes that I have never had before. When it's supposed to load the linked page in the iframe, it instead opens the link in a new tab.

What's strange is I have been able to get this to work before with no problems at all.

I tried even putting the links into the source page that first loads in the iframe, it STILL opens in a new tab.

The hyperlinks:

<div id="subnav"><h2><a href="pages/videothumbs.htm" target="thumbnails">Videos</a> 
            | <a  href="pages/photothumbs.htm" target="thumbnails">Photos</a></h2><!-- End Subnav --></div>

The iframes:

<div id="gallery"> 
<iframe id="view" allowtransparency="true" frameborder="0" src="Pages/mediastart.htm"></iframe>
  <br>
  <iframe id="thumbnails" allowtransparency="true" frameborder="0" src="Pages/mailinglistform.php"></iframe>
  <!-- End Gallery -->
</div>

All the formatting on these are being done with CSS, this is the code for them:

div#subnav
{
position: relative;
margin-left:auto;
margin-top:auto;
margin-right:auto;
text-align:center;
}

iframe#view
{
text-align:center;
width:600px;
height:300px;
}

iframe#thumbnails
{
overflow-y:hidden;
overflow-x:auto;
width:600px;
height:100px;
}

div#gallery
{
position: relative;
margin-left:20%;
margin-top:25%;
margin-right:auto;
text-align:center;
}

I really appreciate any help given. smile
-Raven

Re: Links target to iframe, but open in a new tab

I'm on really slow internet access at the moment, so I can't double check this, but I believe you also have to assign each iframe a name:

<iframe name="iframename" id="id">

If I remember correctly, you have to set the iframe name in order to target it properly. Just give it the same name as the id.

If you haven't replied by the time I get back to proper high speed internet access, I'll double check.

Re: Links target to iframe, but open in a new tab

Yes, although "name" is supposed to be deprecated and replaced by "id", that doesn't apply to iframes which still use "name="...".

Re: Links target to iframe, but open in a new tab

falkencreative wrote:

I'm on really slow internet access at the moment, so I can't double check this, but I believe you also have to assign each iframe a name:

<iframe name="iframename" id="id">

If I remember correctly, you have to set the iframe name in order to target it properly. Just give it the same name as the id.

If you haven't replied by the time I get back to proper high speed internet access, I'll double check.

I have an ID defined for each of them, and the links are targeted to the frame's ID, but the link always opens in a new window.

Re: Links target to iframe, but open in a new tab

Wickham wrote:

Yes, although "name" is supposed to be deprecated and replaced by "id", that doesn't apply to iframes which still use "name="...".

So, what you're saying is I should also define a "name" property?

Re: Links target to iframe, but open in a new tab

Yes, use name=".."

<iframe name="thumbnails" id="thumbnails" allowtransparency="true" frameborder="0" src="Pages/mailinglistform.php"></iframe>
  <!-- End Gallery -->
</div>

The id probably isn't needed unless you are using it for some other function.

Re: Links target to iframe, but open in a new tab

Wickham wrote:

Yes, use name=".."

<iframe name="thumbnails" id="thumbnails" allowtransparency="true" frameborder="0" src="Pages/mailinglistform.php"></iframe>
  <!-- End Gallery -->
</div>

The id probably isn't needed unless you are using it for some other function.

That was it, I completely didn't notice it because I was focusing on the 'target' property in the links, and not whatever missing property that may have been in the iframe itself. I actually recall now, when I first got a hold of the iframe code, I was confused why there was an id and a name, and now I see why. The 'name' had to be there,and you couldn't just use 'id' alone. lol

Thanks a lot man, it means a lot.

Last edited by rsrwebs (2009-09-13 16:01:14)