iframebuster before

Before Inserting the iframe buster

crunchydata.com–      You may have seen your own website shown on one of those large, fake sites that pretend to offer website reviews or previews. Then you tried clicking on your site preview or link, only to find yourself in an endless loop inside the fake site. Those “previews” and thumbnails are showing your site in something called an “iframe,” which means at the very least, they’re stealing your bandwidth.

Very annoying.

This has created more than just an irritation for site owners who have worked hard to develop value on their sites, especially when a scraper site outranks the original site. Google is actively addressing this by asking people to report scraper sites, but any tactic that spammers can use to steal content without having to work for it is bound to continue.

iframekiller after image

After inserting JavaScript code iframe killer, page is blank. When the preview button is clicked, your site breaks the frame, closes the scraper site, and opens your site.

There is a simple solution to stop these content and bandwidth thieves from showing  your WordPress blog or website in iframes, and you can actually turn the tables on them by essentially turning their fake links into real links to your site. Because when you place the following code into your header, your site will break out of the iframe and the visitor who clicks on  your site preview or thumbnail will be taken directly to your site. This method is called a “frame killer” or “frame buster.”

Actually, there is more than one solution, but it’s important to use the X-Frame code to override attempts to thwart your framebuster or frame killer, and this code also works in all browsers.

Paste this code carefully into your header.php file (Appearance>Editor, then locate and open the file). Place it immediately before the <body> tag:

<script>
if (self == top) {
var theBody = document.getElementsByTagName(‘body’)[0]
theBody.style.display = “block”
} else {
top.location = self.location
}
</script>

Code by JavaScript Tutorial (CC BY-NC-SA 3.0)

I had tried a simpler version, but found that it didn’t work on the more aggressive scraper sites, so this version, found on Javascript.info works on every site on which I found my website framed. Their article explains the concept well, and if you like to know how things work when you use them, visit their site to read more.

If you happen to use the Suffusion WordPress theme, then this method is even easier. Simply navigate to:

Suffusion Options>>Back End Settings>>Custom Includes

Scroll down to “Got Java Script?” And down to “custom header Java Script,” then paste this in:

if (self == top) {
var theBody = document.getElementsByTagName(‘body’)[0]
theBody.style.display = “block”
} else {
top.location = self.location
}

So in Suffusion, you delete the <script> tags because they are already set up for you. Easy peezy.

Try it out, and let us know in the comments how this works for you. Sooner or later, your site WILL be framed.

Pin It on Pinterest