JavaScript To Stop Frames

The following section of JavaScript will detect if anyone is viewing your page in a frame. If they are then the code will redirect them to your site. It essentially stops people using frames to poach your content and stops online proxy software from viewing your site.

1
2
3
if(top.location != location){
 top.location.href = document.location.href;
}

All you have to do is include this code either in your script tag or your JavaScript includes. Quite a neat little trick really.

Category: 

Share:

  • Add news feed
  • Bookmark this on Delicious

Add new comment