views:

371

answers:

3

I have looked and tried but don't see where I can stop some being able to browse my site through an IFrame or Thickbox?

I want to stop banned members from accessing the site through proxy sites that give the end user the ability to browse through a IFrame. I know nothing may be full proof but it's still worth the question.

+6  A: 

Ah, but here is the response to Jeff Atwoods blog post. (the anti-anti frame breakout) it is possible.

Go figure, it was a question on Stackoverflow as well. Posted by guess who? The answer is similar to the link I posted:

if(top != self) {
 top.onbeforeunload = function() {};
 top.location.replace(self.location.href);
}
altCognito
These methods aren't, but there is another way, as shown by the second link.
altCognito
What happens if I were to define a new (blank) alert() method on the top page...which version would the child call? Interesting expirement, but if the child called the wrong method...the blank alert() would prevent the alert from being shown, thus busting the anti-anti frame breakout.
Justin Niessner
...nothing happens. As I expected. Doh. Sounds like a good candidate for code golf!
Justin Niessner
Yeah, this is beyond my time limits as it is, it looks as if the game has already been in progress for quite some time.
altCognito
+13  A: 

Check out SO's own Jeff Atwood's comments about this problem...

Coding Horror - We Done Been ... Framed!

What it boils down to is that there is no RELIABLE way to do this. You can try a frame breakout, but malicious coders will always be able to add a little more code and get around any "protection" you might add.

Justin Niessner
Beat me to it. I'm removing my answer as it is almost an exact duplicate of yours.
T Pops
There was a response to his Jeff Atwoods blog post that does work (and in fact, Jeff Atwood refers to his work in his blog post), I've updated my answer in response. The post I give is newer, it's just 5 days old.
altCognito
+1  A: 

altCognito is right, you want to bust a frame breakout.

Below is the source code from the post altCognito sent you.

<script type="text/javascript">
if (top.location != self.location)
top.location = self.location;
</script>

However, I think you might even want to go further with it. You may want to have a series of checks looking for not only the top but also parent and window.

<script type="text/javascript">

var self = self.location;
var top = top.location;
var parent = parent.location;
var window = window.location;

if (top != self || parent != self || window != self  )
window = self;
</script>
Max Felker