Digital UK Design Blog

iFrame Buster Script!

April 14, 2009 | Tools | Gary Hartley | 2 Comments »

Do you like this story?

The following script will stop your website from being encased within an iFrame. With the recently social media toolbars that have started to pop up it has become harder and harder to launch successful linkbait campaigns through traffic streams such as Social Media.

Digg is the latest culprit when they introduced their Social Media Toolbar, effectively killing linkbait in the process.

Digg toolbar

Basically websites like Digg have the potential of referring thousands upon thousands of visitors to your website if an article or post becomes popular, now what they do is refer that click into an iframe setup where they effectively remain on the Social Media website. The visitor therefore never physically steps foot on your website and no traffic is recorded.

Wikipedia have a great article on ‘Framekiller‘ and offers the following scripts to elinimate your website from being encased within an iframe.

Place either script with the <head> tags at the top of your web page.

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

Variation that lets the user know why they are being redirected with the use of a pop-up alert:

<script type="text/javascript">
    if (top !== self) {
        alert('The URL '+self.location.href+' cannot be viewed inside a frame.  You will be redirected.');
        top.location.href = self.location.href;
    }
</script>

Limitations

Because this is a client-side Javascript solution, it relies on the end-user’s browser to enforce their own security. This makes it a beneficial but unreliable means of disallowing your page to be embedded in other pages. The following situations may render the script above useless:

  • The user agent does not support JavaScript.
  • The user agent supports JavaScript, but this support has been opted out of by the user.
  • The user agent’s JavaScript support is flawed or partially implemented.
  • The user agent’s behavior is modified by a virus or plug-in (possibly without the user’s knowledge) in a way that undermines the framekiller script.

Other useful scripts and tools

Related posts:

  1. Amazing 3D Street Art Collection
  2. Frog’s Christmas Countdown 2008
  3. Is Twitter digging DIGGs grave?
  4. Google Sidewiki: A top tip for site owners
  5. Twitter infographic celebrating 5 year anniversary

Author :

Gary (aka Frog) is the co-founder of The Floating Frog and has written in excess of 200+ articles on all things design and web related. If you'd like to guest post on The Floating Frog on a subject you are really passionate about then please get in touch. For more information head over to our write for us page.

2 Responses so far

  1. 網站製作學習誌 » [Web] 連結分享 Says:


    [...] iFrame Buster Script! [...]


  2. My Latest Favourite Bookmarks – Online Cool Stuff! (24th March 2010) Says:


    [...] iFrame Buster Script! | Frog’s Digital Design Blog – In the last year we’ve seen more and more social bookmarking and short URL companies implementing framed toolbars round sites that they’d ordinarily seen visitors to. This means that you’re effectively losing out on having visitors to your site, you can’t track these people as they are still officially on the toolbar’s website (boosting their stats and advertising income), but by using this script on your website, you can stop these toolbars from working so people see your site properly in full! [...]




Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

©2006 - 2009 The Floating Frog