Ingrid
Ingrid

Reputation: 1081

How to make links inside an IFRAME to open outside this Iframe?

I have created a widget kind of. In reality I put the information in a php file and then I provided the Iframe code for this file to my members.

Considering site A is member's site and site B is my site.

Site A shows the IFRAME:

<iframe src="http://siteB.com/try.php" height="240px" width="286px"></iframe>

When this IFRAME is clicked, it opens a new pop window, because of this code:

<a href="#" onClick="return mbetter('http://siteB.com/chat/new_chat.php?reader=<?php echo $id; ?>')"><?php echo $status_img; ?></a>

So far so good.

Now the problem is this pop up window also has a link. How can I make this link open outside this IFRAME, to be more specific, to take them to Site B , my site . At the moment this link opens inside the iframe and it can't be used this way.

This last link is:

<a onclick="return targetopener(this,true)" target="_top" href="http://siteB.com/services.php">

It works perfectly in my site but not in an Iframe. I know I complicated myself a little with this iframe but I adapted a solution to my poor knowledge. I'm opened to new solutions though, if this link can't be opened outside the Iframe. Thank you in advance!

Upvotes: 0

Views: 10719

Answers (2)

Priya
Priya

Reputation: 11

You can use this base tag. Place the tag in the iframe. Should solve your issue.

Upvotes: 1

HenryGuy
HenryGuy

Reputation: 254

Try changing target to _parent if you want the link to open in the previous window (it's parent window). So if site B opens up a pop-up with site A inside that then must refer them back to Site B then this should open the link in the window that spawned the popup.

But if you want it to open a new window that leads to your website then of course use _blank.

Upvotes: 6

Related Questions