www.cryer.co.uk
Brian Cryer's Web Resources

How to prevent a page from being framed

To prevent a page from being framed by another site, include the following:

<script type="text/javascript"><!--
if (self != top)
{
   if (document.images)
      top.location.replace(window.location.href);
   else
      top.location.href = window.location.href;
}
// --></script>

It would be wise to include this at the top of the file, preferably in the <head> section or at the top of the <body> html.

What this script does is to redirect the browser to your original page if it is being shown within a frame. This script is in effect allowing your page to break out of a frame.

This is useful if you believe that another site may be showing your page within a frame and you wish to prevent it.

A word of caution: if you use frames on your site then this JavaScript will prevent you from framing your own page and this may not be desirable.