How to Get Rid of Any Frame (Including the DiggBar)

Written by Christopher Null on April 11th, 2009

God bless Danny Sullivan.

Buried in the text of this awesome post is the simple code for breaking your site out of any page that tries to frame your content. (Hello DiggBar!)

Danny said he couldn’t get the entire code to show up in his post, so I’m pasting it here (in part so I’ll have a permanent reference for it — but you can use it too). I’m using it on ALL my sites and it works like a dream.

Note that this script simply pops the page out of the frame and displays it normally. It doesn’t, as some sites have done, display a rude message, thus robbing you of traffic and the visitor of the chance to check out your stuff. This method makes a lot more sense to me… Here’s what it looks like if you try to visit the page with the DiggBar.

And here’s that code… just cut and paste to the <head> section of your site (though the top of the <body> section works too).

<script type=”text/javascript”>
<!–
if (top.location!= self.location) {
top.location = self.location.href
}
//–>
</script>

All hail Mr. Sullivan!

URL Shorteners: Which Shortening Service Should You Use?

 

Leave a Comment