The Web Design Group presents:

Frames FAQ: Avoiding getting 'framed'


Is there a way to prevent getting framed?

"Getting framed" refers to the technique of using an existing frameset to display someone else's document against his wishes into the current display. This can happen quite easily if one of the documents in the frames uses a link that does not use the TARGET attribute, as the destination of that link will be displayed in the current frame.

To avoid "framing" other people's documents, you must add TARGET="_top" to all links that lead to documents outside your intended scope.

Unfortunately, there is no way to specify that a particular document should be displayed in the full browser window, rather than in the current frame. The only workaround is to configure the server to send out Window-Target: _top in its HTTP responses, but this is not something that all authors can do.

The HTML specifications say that META can be used to mimic HTTP responses in HTML. However, inserting <META HTTP-EQUIV="Window-target" CONTENT="_top"> in the document does not work as expected.

Another attempt is to use <BASE TARGET="_top"> in the document, but this only specifies the default target frame for links in the current document, not for the document itself.

If the visitor has Javascript enabled, the following script will automatically remove any existing framesets:

<SCRIPT LANGUAGE=JAVASCRIPT>
<!--
if (top.frames.length!=0)
  top.location=self.document.location;
// -->
</SCRIPT>
An alternative is
<SCRIPT LANGUAGE=JAVASCRIPT>
<!--
function breakOut() {
  if (self != top) 
    window.open("my URL","_top","");
}
// -->
</SCRIPT>
</HEAD>
<BODY onLoad="breakOut()">

Table of contents ]


Web Design Group
Last updated: 31 Jan 1998
Copyright © 1996 Arnoud "Galactus" Engelfriet.
E-mail: galactus@htmlhelp.com.