# HTML: when entering a site, remove all frames

**URL:** <https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974>\
**Category:** Miscellaneous and Personal Stuff I Must Share\
**Created:** [February 11, 2001, 2:08am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974 "2001-02-11T02:08:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr.Sheepshead](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@Mr.Sheepshead](https://boards.straightdope.com/u/Mr.Sheepshead)\
**Post date:** [February 11, 2001, 2:08am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/1 "2001-02-11T02:08:00Z")

</div>

When a user enters a site for the first time, is there a quick and easy way in HTML to remove all frames that are left over from other websites? As in, someone clicks on a link at (let’s say) Snopes that leads to your index.html and your index.html contains instructions to remove all frames (such as the left frame at Snopes). The only way I know of requires the people at Snopes to put in TARGET="\_top" in the A tag. I’m looking for a way to insert the code into _my_ page instead of making someone else add it.

---

<div class="post-metadata">

**Author:** ![TheNerd](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@TheNerd](https://boards.straightdope.com/u/TheNerd)\
**Post date:** [February 11, 2001, 2:42am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/2 "2001-02-11T02:42:38Z")

</div>

You can test to see if they came from your domain (though I don’t know the code for that off the top of my head, the referrer should be available). If it’s not your site, reload with target=\_top.

---

<div class="post-metadata">

**Author:** ![techchick68](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@techchick68](https://boards.straightdope.com/u/techchick68)\
**Post date:** [February 11, 2001, 2:57am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/3 "2001-02-11T02:57:18Z")

</div>

To the best of my knowledge the tags follow as such this example:

```auto

<a href=" **newpage.html**" target="_top"><FONT SIZE="1">Break out of<br> someone elses<br>frames here.</FONT></a>

```

newpage.html meaning the page you want to load in an original frame.

Hope this helps and I hope the vB coding doesn’t get messed up 🙂

---

<div class="post-metadata">

**Author:** ![techchick68](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@techchick68](https://boards.straightdope.com/u/techchick68)\
**Post date:** [February 11, 2001, 2:58am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/4 "2001-02-11T02:58:34Z")

</div>

Damnit, sorry Euty, Unca and Coldy, didn’t mean for **THAT** to happen!!! You can wrap it if you need to!

\< sigh \>

---

<div class="post-metadata">

**Author:** ![techchick68](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@techchick68](https://boards.straightdope.com/u/techchick68)\
**Post date:** [February 11, 2001, 3:02am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/5 "2001-02-11T03:02:09Z")

</div>

Shoot, the Pit must be draining my brain power.

Mr. Sheephead,

That is the code (ack hope it gets fixed soon) that you insert on _your_ page to break out of frames. The font size and such after the main …target"\_top"\> is up to you.

\< blush \>

---

<div class="post-metadata">

**Author:** ![SmackFu](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@SmackFu](https://boards.straightdope.com/u/SmackFu)\
**Post date:** [February 11, 2001, 3:58am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/6 "2001-02-11T03:58:52Z")

</div>

It’s pretty simple. Add this bit inside your \<body\> tag:  
**onLoad="if (self != top) top.location = self.location"**

---

<div class="post-metadata">

**Author:** ![BornDodgy](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@BornDodgy](https://boards.straightdope.com/u/BornDodgy)\
**Post date:** [February 11, 2001, 1:38pm UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/7 "2001-02-11T13:38:14Z")

</div>

My boss has the sweetest frame remover on earth - she didnt make it with html though…

While the page is being reloaded without the frames it says “frames are evil”

dodgy

---

<div class="post-metadata">

**Author:** ![OpalCat](https://avatars.discourse-cdn.com/v4/letter/o/8edcca/32.png) [@OpalCat](https://boards.straightdope.com/u/OpalCat)\
**Post date:** [February 12, 2001, 2:20am UTC](https://boards.straightdope.com/t/html-when-entering-a-site-remove-all-frames/53974/8 "2001-02-12T02:20:18Z")

</div>

\<SCRIPT TYPE=“text/javascript” LANGUAGE=JAVASCRIPT\>

```
&lt;!--
if (top.frames.length!=0)
top.location=self.document.location;
// --&gt;

&lt;/SCRIPT&gt;
```
