Break Out of IFrame Automatically with JavaScript

I’m sure I’m not the only webmaster who gets a little peeved when other websites link to your site but enclose your site in an IFrame with their site navigation or banner ads on the top frame. Well, look no further. Here is a great snippet of JavaScript to insert into the HEAD of any/all pages of your site to automatically break out of the IFrame!

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