How to make HTML frames go away when leaving the site

Posted on 2007-07-26
Last Modified: 2010-04-09
I have a cooworker that is making a simple webpage that has two frames. I don't use frames EVER since they are messy, but he is using front page to create his html and it seems like the easiest solution for him. The top frame is a menu and the bottom frame changes depending on the menu item choosen.

How do I make it so that when the user leaves the site, the frames disappear?
How do I make so that the frames disappear on this site, when the user goes to a certain page?

Thanks in advance
Question by:bbcac
    LVL 7

    Accepted Solution

    1. via link: <a href="SamePageURL.html" target="_top">Click here</a>

    <script language="JavaScript" type="text/javascript">
    function breakout_of_frame()
      // see
      // for an explanation of this script and how to use it on your
      // own website
      if (top.location != location) {
        top.location.href = document.location.href ;

    as it says above:
    for an explanation of this script and how to use it on your
    own website
    LVL 75

    Assisted Solution

    by:Michel Plungjan

    Alternatively have
    <base target="_top" />
    in the head of the content page and have
    target="_self"  on the links that need to stay in the frame
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction This warning has to be one of the most commonly issued warnings in the history of PHP.  The article explains why this warning arises and what to do to mitigate the problem. How this Happens HTTP headers include many different kinds…
    Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now