Link to home
Start Free TrialLog in
Avatar of annakellers_pg
annakellers_pg

asked on

Wipe out frames

I want to put code in my pages that will wipe any existing frames in the browsers so I can create my own frames without being in someone elses.  
Avatar of thoellri
thoellri

TARGET=_top ???

Here is the script code:

<script language="JavaScript">
<--
if (top.location.href != location.href)
 top.location.href = location.href;
// -->
</script>

This will check to see if the current page is the "top" document.  If it is not, it will make itself be the top.


Avatar of annakellers_pg

ASKER

Solution not working.
Situation: My site has the browser broken up into 3 frames.
<HTML>
<HEAD>
<META NAME=”description” CONTENT=” Anna Kellers Advanced Site”>
<META NAME=”keywords” CONTENT=”Training, HTML, JAVAScript, JavaScript,
JAVA, Developer, C, Client/Server, Keller, Anna”>
<TITLE>Technical Tutorials, Travel, Reading/Writers</TITLE>
</HEAD>
<!--- 3 Frames split into 2 rows with the 2nd row 2 columns --->
<FRAMESET ROWS="25%,*" border=1 frameborder=2 framespacing=1>
<!--- Frame for Sponsor --->
<FRAME SRC="geostuff.html" name="SPONSORAK" marginwidth=0        
scrolling=”no”>
<FRAMESET COLS="75%,25%" border=1 frameborder=2 framespacing=1>
<!--- Frame for Pages --->
<FRAME SRC="homeak.html" name="PAGESAK" marginwidth=1 scrolling="AUTO"
frameborder=2>
<!--- Frame for Menu --->
<FRAME SRC="menuak.html" name="MENUAK" marginwidth=1 frameborder=2
scrolling="AUTO">
</FRAMESET>
</FRAMESET>
</html>

My subpages run in frame PAGESAK and on those pages is
a return to my home page (just incase they get to a
page without going through my site homepage/frames)
which is a link to above html.  Now PAGESAK fills with
frames, when what I actually want is the original
frames zapped and the new frames opened (instead of
new frames opened within the PAGESAK frame in the currently
subdivided browser).

-----------------------------------------
|  SPONSOR STUFF --- STAYS THE SAME     |
-----------------------------------------
|                             |         |
|                             |  Menu   |
|  Dynamically Changing Pages |  Stays  |
|                             |  The    |
|                             |  Same   |
-----------------------------------------

please help ... we're getting closer.

Place the script that I noted above in the Frame Definition page.  before the <HEAD> statement.

It will destroy the frames.
Avatar of sybe
MasseyM's suggestion should work. I believe that some browsers don't like the "href" after location. Try it without href:

<script language="JavaScript">
<--
if (top.location != document.location)
  top.location = document.location;
// -->
</script>
Actually the most compatible version is
<HTML>
<HEAD>
<META NAME=”description” CONTENT=” Anna Kellers Advanced Site”>
<META NAME=”keywords” CONTENT=”Training, HTML, JAVAScript, JavaScript,
       JAVA, Developer, C, Client/Server, Keller, Anna”>
<TITLE>Technical Tutorials, Travel, Reading/Writers</TITLE>
<SCRIPT LANGUAGE="JavaScript"><!-- // cloak
if (self!=top) top.location = self.location.href;
// uncloak --></SCRIPT>
</HEAD>
<FRAMESET......

Michel
All these examples will however break the back button so perhaps

if (self!=top) setTimeout("top.location = self.location.href",3000);

is a more gentle method...

Michel
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Basically what I said:
Yep

Michel
So, you just repost my answer?  I don't really get it.  Ok, I see.

Come on MasseyM, there is a little more to my answer than a repost if you see my 2 preceding comments... Anna could split the points - or I could post some points. I just felt I had added enough to merit an answer.

Michel
Thanks. Please ask Linda in customer services to help you give some points to MasseyM

Michel