Tjoerie
Tjoerie

Reputation: 25

How to make a link placed inside an IFRAME open in the parent window

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?

Upvotes: 0

Views: 4825

Answers (4)

garryp
garryp

Reputation: 5776

Use target="_parent" on your link.

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

Or from Javascript

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

Upvotes: 2

aldux
aldux

Reputation: 2804

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.

Upvotes: 1

SK.
SK.

Reputation: 4358

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

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

Or to open in a new window:

<a href="http://example.com" 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).

Upvotes: 1

YaManicKill
YaManicKill

Reputation: 183

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

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

Upvotes: 1

Related Questions