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


One Response to “Break Out of IFrame Automatically with JavaScript”

  1. | Zoekmachine Marketing on December 16th, 2009 7:44 am

    Great Post! Sometimes simple things can have the right implications!

Leave a Reply