Skip navigation.

Cast Your Vote for "Fruit Mix" DesignAll recent postsCon 2.0

Don't Let Your Site Get Framed

Looking at my referral logs, I can’t help feeling disgust for all those social networks out there whose members appear to be the most illiterate computer users and the worst offenders on the bandwidth leeching front. Ironically, one of their most popular accomplices is Google Images where those freeloaders tend to harvest links.

Google Images, besides other offenders, displays your site in a frame. Here’s a simple JavaScript snippet to rid of the frame and reload the page to its proper URL:

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

self refers to the current window; top is a reference to the top-level window which contains the current window. In a "frame-less" setting the current window object is also the parent and top object. Otherwise somebody is framing you. Feel free to replace location.href with a URL to some page which extols virtues of good netizens.

Comments

Comment permalink 1 Cliff Spence |
Awesome and timely. Thanks!
Comment permalink 2 Scott |
"worst offenders on the bandwidth leeching front". Can't agree more!
Comment permalink 3 Carl |
Milan, could you expand on the bandwidth-sucking practices of leeches? Perhaps my site isn't attractive enough for folks to want to frame it, but I do see referrals from social network sites. I thought these were clicking-through. How do you know from the logs that they're putting your site into a frame? And how/why is this bad as long as your content is served up? I'm obviously missing something here...
Comment permalink 4 Milan Negovan |
More often than not they go to Google Images, find something that pleases them and then simply copy URLs to their pages, thus serving your content and taking your bandwidth without your consent.

Some sites have the guts to display your site in a frame, again Google being one of them.

I take several measures against leechers, unwanted bots, offending domains, etc, by running an HttpModule I wrote which watches for all these things.

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

TrackBacks

Sorry, TrackBacks are not allowed.

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):