This is a simple page to demonstrate some of the ideas, problems and solutions discussed on my page about frames.

This page is to demonstrate how to break out of a frameset. This is useful if you need to break one of your pages out of someone else's frames or to provide a way to allow someone to print a page of yours without cluttering the printout up with frames.

1) Using a simple HTML link

To break this page out of the frame CLICK HERE

The code to do this is...

<p align="left"><font size="4" color="#0000FF">To break this page out of the frame <a href="frmmainbrk.htm" target=_top>CLICK HERE</a></font></p>

Using JavaScript, several methods are available, all of them work the same, except that the coding is little different. In all cases the main script is put into the HEAD section of the page. The button is placed in the BODY of the page and has the generic code...

<p align="center"><input type="button" onclick="breakoutX()" value="Break out X"></p>

where X is the value for that particular JS function.

2)

<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Hide from old browsers
function breakout1(){
if (top != self) top.location.href = location.href;
}
// Stop hiding from old browsers -->
</SCRIPT>

3)

<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Hide from old browsers
function breakout2(){
if (top.location != location) top.location.href = document.location.href;
}
// Stop hiding from old browsers -->
</SCRIPT>

4)

This method is less attractive because the actual page name has to be specified. Rather tedious, if you've got a lot of pages.

<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Hide from old browsers
function breakout3(){
if (window.top!=window.self) window.top.location="frmmainbrk.htm";
}
// Stop hiding from old browsers -->
</script>

5)

<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Hide from old browsers
function breakout4(){
if (parent.frames.length > 0) parent.location.href = location.href;
}
// Stop hiding from old browsers -->
</script>

This page created 29th October 2004, last modified 31st October 2004


GoStats stats counter