Tuesday, 4 February 2014

How to break out of iframe

There is a simple method I use to prevent pages on my website from being included through an iframe by another website. First I create one file no-iframe.js including
if (top.location!= self.location) {
 top.location = self.location.href
 }

Now you can add this to the header of any page of your website.
<script src="js/no-iframe.js" type="text/javascript"></script>

Now your site wont be "framed"