javascript, iframe - navigate/close parent window from iframe

11,873

Solution 1

In all of the links that you want to affect the parent window do something like this:

<a href="somthing.html" target="_parent">GO THERE!</a>

Or with javascript:

<a href="javascript:window.parent.location = 'somthing.html';" >GO SOMEWHERE!</a>

Solution 2

If all you need to do is change the parent window's location from inside the iframe, it is very simple:

 window.parent.location = 'newWindow.html';

Or if you are using a link, just use it's "target" attribute.

Solution 3

You should use the target attribute <a href="" target="...">

For all the possible values of target, you can go here.

Share:
11,873
zozo
Author by

zozo

Same old me.

Updated on June 28, 2022

Comments

  • zozo
    zozo almost 2 years

    Good day to all.

    I have this setup:

    One page with text/whatever, that also includes an iframe (the page in iframe is created by me so I have access to it, I can modify its content).

    What I need to do is that when I access a link from the iframe to open it on the mother page (navigate).

    Until now I kind of failed to do that so any help would be appreciated.

    For any further info just ask.