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.
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.
This will solve the misery.
I found that
<a href="..." target="_top">link</a>
works too@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): https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
Ex:
target="_parent"
worked great for me. easy and hassle free!window.top
refers to the window object of the page at the top of the frames hierarchy.If you'd like to redirect to another domain without the user having to do anything you can use a link with the property:
as said previously, and then use:
to have it automatically redirect.
Example:
Note: The javascript click() command must come after you declare the link.