Welcome to WebmasterWorld Guest from 54.204.165.156

Forum Moderators: open

Break out of IFRAME

Javascript to detect framing and break out?

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

10+ Year Member



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?

TIA.

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

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



What does your script look like?
7:22 pm on Jun 13, 2003 (gmt 0)

10+ Year Member



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
}
//-->
</script>

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

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

10+ Year Member



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)

10+ Year Member



That code works fine in my version of IE6, testing across domains.
8:31 pm on Jun 13, 2003 (gmt 0)

10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month