Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When someone clicks a link in an iframe, navigate the entire window

Tags:

html

iframe

This seems to be the opposite of a common question, which implies that maybe I'm missing something obvious.

I have a little app that displays some other page (from a different domain) inside an iframe, with my header on top. So far, so good. But when someone clicks a link on that inner page, it just navigates the iframe - I want it to navigate the entire page instead (including, and especially, updating the URL in the URL bar).

This is basically the opposite of clickjacking. I just want the navigation to work as if it weren't an iframe. Is there an easy way?

like image 828
apenwarr Avatar asked Feb 12 '12 07:02

apenwarr


2 Answers

The content in the iframe can modify the link's target: use _parent or _top.

<a href='#aboutus' target='_parent'>About Us</a>
like image 74
rektide Avatar answered Oct 20 '22 12:10

rektide


If the contents of the <iframe> are in a different domain you can't do it due to security reasons.
If you have access to the other domain and html code you could do something like this on the link:

href="javascript:parent.window.location.href='http:/google.com'
like image 34
elclanrs Avatar answered Oct 20 '22 10:10

elclanrs