Can I protect my pages from being framed by someone else?

With frames it is possible that someone else is 'borrowing' your pages. By creating a site with frames someone else can use its own navigational system but your pages with the actual information. To protect your pages from this you can use a JavaScript to test for this and if so, correctly load your page.

<SCRIPT language="javascript">
if (self != top) {
top.location.href = self.location.href

This script checks if the top window is the same as the window in which the page is loaded. If this isn't true, it means the current file is contained inside a frame. Then this situation is corrected by loading the current page as the top frame. Put this script inside the HEAD section of a page that you want to protect.

Back to the FAQ main page

  Copyright © 1996 - 1999 Rob Schlüter,   (last updated 1999/03/01)