Redirect parent window from an iframe action

Redirect parent window from an iframe action

What JavaScript do I need to use to redirect a parent window from an iframe?
I want them to click a hyperlink which, using JavaScript or any other method, would redirect the parent window to a new URL.


Solution 1: = ""; 

As stated previously, will redirect the parent iframe.

Solution 2:

I found that <a href="..." target="_top">link</a> works too

Solution 3: = ""; refers to the window object of the page at the top of the frames hierarchy.

Solution 4:

or an alternative is the following (using document object)

parent.document.location.href = "";

Solution 5:

target="_parent" worked great for me. easy and hassle free!

Solution 6:

@MIP is right, but with newer versions of Safari, you will need to add sandbox attribute(HTML5) to give redirect access to the iFrame. There are a few specific values that can be added with a space between them.

Reference(you will need to scroll):


<iframe sandbox="allow-top-navigation" src=""></iframe>