While looking at my logs the other day, I noticed a lot of extra traffic from an external source for one of my sites, unsure of what it was I went to look. The owner of the other site had wrapped my site in an iframe, and covered it in adverts of his or her own making my site look awful. This I wasn't happy with, but without any access to the site in question, I couldn't change what the person was doing.
My site doesn't use iframes at all, so I knew I could safely put a little bit of code into every page to make a quick test when the page loads to see if it is the 'top' level page, if it is nested at all then we can pop it out of the nesting.
framebuster.js
<script type="text/javascript">
if (top != self)
top.location.href = self.location.href
</script>
This is a simple test, if the url of the top level page is not the same as the current elements url, update the top level page to be that of the frame and bust us out of the iframe.
A simple solution, to an annoying problem that shouldn't exist - the blatant theft of content.
Similar Articles from the web
Framebusting Javascript
In reply to this
Spinner
said
And used in conjunction with the...
You know me, I'm the kind of guy that does what you say I should do!
So I went right ahead and implemented this script, all over ofc.
Then I went to try your previous recommendation, the iphone-tester...
:-P
What wa that about content-theft? (-:
In reply to this
TimIgoe
said
ROFL
haha, I hadn't even considered that side effect there :D rather useful little snippet though for when people are genuinely stealing / framing your site.