How to block showing your site in IFrame (Anti-iframe)

Recently, I found that one of my popular sites is shown as part of other site. So visitors of that not-mine site, being on that site, can access all the services of my sites. They used my site content and services via iframe and took benefits from my site.

Below is the solution how to prevent this, i.e. block showing your site content via iframe. The solution is pretty simple.

Put this javascript code on all your pages:

<script>if(self != top) { top.location = self.location; }</script>

If one site will show your site in iframe, it will redirect the browser to your site directlty, so that user will will your site in browser as it is.

 

2 thoughts on “How to block showing your site in IFrame (Anti-iframe)”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>