homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Break out of IFRAME
Javascript to detect framing and break out?

 6:41 pm on Jun 13, 2003 (gmt 0)

I already use Javascript to detect whether my site is framed and break out, but this does not seem to work for sites framing my site in an IFRAME.

Is is there a reliable way to detect if your page is in an IFRAME and break out of it?




 6:46 pm on Jun 13, 2003 (gmt 0)

What does your script look like?


 7:22 pm on Jun 13, 2003 (gmt 0)

This JS code works fine to break out of "normal" (non-IFRAME) framing:

<script language="Javascript">
if (top.location!= self.location) {
top.location = self.location.href

But it doesn't seem to work with an IFRAME.


 7:55 pm on Jun 13, 2003 (gmt 0)

Interesting, the code I posted above appears to break out of an IFRAME in Mozilla and Netscape, but does odd things sometimes in Opera 6.05 (like displays the keword metatag content!).

I guess the only browser it doesn't work right is in IE6 and Opera.


 8:10 pm on Jun 13, 2003 (gmt 0)

That code works fine in my version of IE6, testing across domains.


 8:31 pm on Jun 13, 2003 (gmt 0)

OK, I think I see what I was doing wrong in IE. Thanks for the help.

It still does not work in Opera 6.05

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved