JavaScript To Stop Frames

27 May, 2008 | JavaScript

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.

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.

Write a comment