homepage Welcome to WebmasterWorld Guest from 54.226.180.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
The return of FrameBusting.
Diggbar heralds the return of scumy "Framing" of other's content.
grelmar




msg:3891497
 4:47 pm on Apr 13, 2009 (gmt 0)

You know, I haven't thought much about frame breaking for years. I'd thought the problem had (mostly) gone away, and web developers had cottoned on to the idea that including other people's content within a frame on your own site was dirty pool, and a bad idea.

I guess Kevin Rose and the folks at Digg never got the memo, because this is essentially what the new Diggbar is doing.

So, I thought it might be worth returning to this old problem with a couple of quick and dirty ways to defeat the problem.

First off: Why is Framing someone else's content bad?

When you include someone else's content within a frame on your site, you take away a lot of the context. The end user doesn't see the URL of the framed content (unless he views source or page info, and 99.9% of users don't even know they can). You take away potential revenue from the framed content owner by surrounding the frame with your own ads. You also soak up the framed content owner's bandwidth without providing any real benefit to them in return.

Basically, it's dirty pool, pretty much everyone agrees, and it really stopped being a problem years and years ago.

Digg has brought it back in a big way

The new Diggbar is a way of showing users content from external sites, while removing the external site's URL, and giving Digg another opportunity for ad revenue.

How do I stop it?

There are two basic methods. The first involves checking for referrer information and performing a custom action based on referrer. The second is to simply break your pages out of any frame.

Method 1: Referrer checking

Essentially, you're setting up rules for when you're site detects referrer frames from specific sites. The advantage of this is you get to block specific sites from framing your site in "less than honourable" ways (ie: Diggbar), and allowing your site content to be displayed within a frame for sites that you can see a potential benefit from the practice, and who do it in a way that allows the end user to see your URL and visit directly if they want to (ie: Google Image Search).

In PHP, John Gruber at Daring Fireball [daringfireball.net] provides a good method for this.

<?php
if (preg_match('#http://digg.com/\w{1,8}/*(\?.*)?$#',
$_SERVER['HTTP_REFERER']) ) {
echo "<p>Special message for Digg users here.</p>";
exit;
}
?>

There are also server side methods of accomplishing the same thing, if you're using static HTML or some other web language. You'll have to look up the specifics of this depending on your server/hosting configuration.

The downside to doing things this way is that you end up creating rules for every site you detect framing your content. This can become tough to track, and end up becoming quite a long list that is both difficult to maintain, and as the list grows, adversely affect site performance.

Method 2: Go Nuclear, break all frames.

This is something I've done with pretty much every site I've built for the past decade. It's a part of every HTML template I have, and gets included in the header for all my PHP sites as well.

Inside the head, just insert the following handy snippet of Javascript. I'd credit the orignal author, if I could remember who it was or where I got the script from:

<script>
if (parent.frames.length > 0) {
parent.location.href = self.document.location
}
</script>

The downside to this is that your content will break out of every frame. Period. And this isn't for everyone. If you rely on Google image search to drive traffic, for instance, this is probably a bad idea.

Also, if you use frames within your site (shame on you!), then this script will rapidly cause you grief. However, there are ways of manipulating this script so that your content will load into whatever frameset (frames are evil) you're using.

Personally, I avoid frames as a design tool. And none of my sites are image heavy or rely on image search for traffic. In fact, I can't think of a good reason why my content should be included in someone else's frameset. As I result, I'm quite happy with the nuclear option.

 

The Contractor




msg:3891561
 6:30 pm on Apr 13, 2009 (gmt 0)

If you rely on Google image search to drive traffic, for instance, this is probably a bad idea.

Actually it is a good idea. If the person is going to steal your image...may as well be forced to do it from the site where it resides.

kaled




msg:3892057
 2:18 pm on Apr 14, 2009 (gmt 0)

It's been some time since I've worried about breaking frames, but this should work better...

if (top != self) top.location.replace(self.location.href);

This will ensure that the framing site is overlooked by the forward and back buttons. Also...

<base target="_top">

Kaled.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved