Breaking Out Of Frames
= Index DOT Html by Brian Wilson =

Main Index | Element Index | Element Tree | HTML Support History
The Problem | Some Solutions

The Problem
Many people view the use of frames as an evil scourge on the face of this planet. Any arguments to the contrary will have no effect on the many readers ...and authors, who feel this way.

Which leads to the common scenario many people find themselves in: finding yourself "trapped" in a frameset. How do you easily break out of frames?
Some Solutions
HTML Solution
Use "target=_top" in all hyperlinks or the <base TARGET="_top"> in the HEAD element. This doesn't solve the problem of the current page being trapped in a frameset, but all subsequent pages opened will not be in a frameset.
<a href="" target="_top">Link text</a>
Javascript Solution
Using an inline script with an event handler or invoking a function in a SCRIPT block, the current document can be forced into the entire main window if it is not currently in that state. Note that the Javascript function example is more versatile in that it can be contained in a reusable external script.
Example 1 (Inline script, BODY onLoad example):
<body onload="if (window != { top.location.href=location.href }">
Example 2 (External Javascript function, BODY onLoad example):
   <script language="JavaScript">
   function breakOut()
      { if (window != top) top.location.href = location.href; }
<body onload="breakOut();">

Boring Copyright Stuff...