HOW TO: Remove Digg’s new DiggBar from your website

So Digg have released their wonderful new DiggBar product, to a lot of fanfare, excitement and, well… criticism. I’ll let other people cover each angle. In the meantime, if you want to prevent your site from being loaded with the DiggBar, just drop this code into the top of your page (or in an external JavaScript file if you already have one that loads on every page):

<script type="text/javascript" language="JavaScript">
// Break out of frames
if (top.location != location) {
    top.location.href = document.location.href ;
}
</script>

Basically, it just compares the current document (in this case your website) to the “top” document available in the browser. If your site has been loaded via the DiggBar then the “top” document will be Digg, so they will be different. When those 2 documents are different, it will automatically redirect the entire browser to your website. Done and done.