How to make links break out of iframe when you only control the iframe page (not the framed pages)?

Christian picture Christian · Jun 29, 2009 · Viewed 22.8k times · Source

I have a site that displays other sites through an iframe on certain pages. It does this in order to display a toolbar that is relevant to the reader (like Facebook and Owly does). However, when the user chooses to leave the original site I want the bar to go away. As you might gather, I don't control the sites in the iframe, and they're on another domain than the iframing page.

I tried target="_parent" on the <iframe>, no luck. Then I tried various scripting solutions, but they all fail due to the same domain restriction. My last try was to have a timeout check for changes in the iframe URL, but iframe.contentWindow.location.href is restricted when page is on another domain (unlike the object iframe.contentWindow.location which I found a bit weird).

Any solutions to this problem? I know iframes aren't the hottest thing around, but they do the job in this case.

Answer

MystikSpiral picture MystikSpiral · Jun 29, 2009

Try target=_top That should open the page in the full body of the window.