admin管理员组

文章数量:1431997

I have a JS game that's running inside an IFRAME, which is scaleable and all that fancy stuff.

The game contains a link to the next page, and the link works brilliantly.

Problems is that the link is opening inside the IFRAME and not the parent window. I need the flow to continue in the parent window and not the iframe.

the way the next page is linked in the IFRAME is like this:

LINK_BUTTON="data.php",

That's the only piece of code pointing out the link. To my regret I can't FIDDLE this because of disclosure issues.

Can anyone help me out?

I have a JS game that's running inside an IFRAME, which is scaleable and all that fancy stuff.

The game contains a link to the next page, and the link works brilliantly.

Problems is that the link is opening inside the IFRAME and not the parent window. I need the flow to continue in the parent window and not the iframe.

the way the next page is linked in the IFRAME is like this:

LINK_BUTTON="data.php",

That's the only piece of code pointing out the link. To my regret I can't FIDDLE this because of disclosure issues.

Can anyone help me out?

Share Improve this question edited May 28, 2015 at 10:41 Aurelio 25.9k9 gold badges61 silver badges64 bronze badges asked May 28, 2015 at 10:37 TjoerieTjoerie 251 silver badge9 bronze badges 2
  • Is LINK_BUTTON a javascript variable? – aldux Commented May 28, 2015 at 10:39
  • Yes it is. It's the first line next to the "var". – Tjoerie Commented May 28, 2015 at 10:39
Add a ment  | 

4 Answers 4

Reset to default 2

Use target="_parent" on your link.

<a target="_parent" href="data.php">link</a>

Or from Javascript

window.top.open("data.php");

Use the target attribute. This will force the link to open in the parent.

<a target="_parent" href="data.php">Next</a>

You can just set the target attribute. To open in the current top window (top frame):

<a href="http://example." target="_top">Link Text</a>

Or to open in a new window:

<a href="http://example." target="_blank">Link Text</a>

There's also _parent for the parent window (not necessarily the top) and _self for the current window (the default).

The short answer, as given above, is really to add target="_parent" attribute to your anchor (link).

The catch here is that you'll have to find in the javascript code where the LINK_BUTTON is used to generate the rendered link, and then in the code, add the target attribute.

本文标签: javascriptHow to make a link placed inside an IFRAME open in the parent windowStack Overflow