breaking out of frameset problem

Discussion in 'Javascript' started by David, Jun 27, 2003.

  1. David

    David Guest

    Hi,

    I use the following code to force the page to load into the intended
    frameset (navigation purposes) if visitors come to pages in a certain
    section of the site from search engines/external links.

    <script language="JavaScript"><!--
    if (parent.location.href == self.location.href)
    window.location.href = 'index.htm?pageone';
    //--></script>

    This works very well BUT.... if the visitor hits the browser back button all
    it does is reload the page and frameset unless you either use the onsite
    navigation or call up the previous pages with the carat by the back button.

    Is there any way of making sure that if the visitor simply hits the back
    button they break out of the frameset and return to wherever they cam from?

    Thanks
     
    David, Jun 27, 2003
    #1
    1. Advertisements


  2. Try
    if (top == self) {
    location.replace('index.htm?pageone');
    }

    Using location.replace means that the current page is replaced, even
    in the history, with the new one.

    Consider whether it is a good idea to force how people see your page,
    and that your frameset depends on javascript. Perhaps you should have
    a different frameset for this that depends on javascript, and a
    non-javascript one for people who enter at the front page.

    /L
     
    Lasse Reichstein Nielsen, Jun 27, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.