- 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
- Description:
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.
- Example:
<a
href="http://www.example.com/"
target="_top">Link text</a>
- Javascript Solution
- Description:
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 != window.top)
{ top.location.href=location.href }">
- Example 2 (External Javascript function, BODY onLoad example):
<head>
<script
language="JavaScript">
<!--
function breakOut()
{ if (window != top)
top.location.href = location.href; } -->
</script>
</head>
<body
onload="breakOut();">
|