Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Anyone From Viewing My Site Using an IFrame

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.

like image 713
dvancouver Avatar asked Jun 23 '09 19:06

dvancouver


3 Answers

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.

like image 182
Justin Niessner Avatar answered Nov 11 '22 15:11

Justin Niessner


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);
}
like image 36
cgp Avatar answered Nov 11 '22 15:11

cgp


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> 
like image 28
M.W. Felker Avatar answered Nov 11 '22 14:11

M.W. Felker