Web Analytics Made Easy -
StatCounter How to put a page back in its frameset? - CodingForum

Announcement

Collapse
No announcement yet.

How to put a page back in its frameset?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to put a page back in its frameset?

    A number of search engines (including Google) now happily index the content pages from within a frameset. This means that when a searcher clicks on a link from the search engine, they arrive at the content page devoid of its navigation and other important elements. Is there a clever javascript (or other) method of detecting if a page is missing its frame and then force it to display back within its frameset?

  • #2
    1. stick a redirect into the <head> of the content page (content.html) like this:
    Code:
    <script language=javascript>
    <!--
    window.location="[b]frameset.html?[i]content.html[/i][/b]"
    //-->
    </script>
    2. stick this into the <head> of the frameset page (frameset.html):
    Code:
    <script language=javascript>
    <!--
    window.[b]mainframe[/b].location = window.location.search.substr(1)
    //-->
    </script>
    mainframe is the name of the frame where you want the content to appear.

    this means that when anyone stumbles across content.html they will be sent to frameset.html and 'content.html' will be sent in the location.search (the bit in the address starting with a '?'. when frameset.html opens, the bit after the '?' ('content.html') is loaded into the mainframe.

    ok?
    neil.c

    Comment


    • #3
      you're on the right track, neil, but you forgot a couple of details. what happens if you don't have any extra information appened to the url?

      i'll copy and paste my script from the old forum here:

      anything in bold, you have to change to fit your site.

      this first part goes in the page, where you create your frames. ie, frames.htm
      <SCRIPT>
      function frame_saver()
      {
      if (self.location.search)
      {
      self.FRAMENAME.location = "http://www.DOMAIN.com" + self.location.search.slice(1);
      }
      }

      self.onload = frame_saver;
      </SCRIPT>

      this second bit goes in any frames that don't change, like frames you use for navigation.

      <SCRIPT>
      if (self == top) {self.location = "http://www.DOMAIN.com/frames.htm"; }
      </SCRIPT>


      this last part goes in all of the pages that are in the main frame; the ones that you want to be able to bookmark.

      <SCRIPT>
      if (self == top)
      {
      var url = self.location.pathname;
      self.location = "http://www.DOMAIN.com/frames.html?" + url;
      }
      </SCRIPT>
      bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

      i am a loser geek, crazy with an evil streak,
      yes i do believe there is a violent thing inside of me.

      Comment


      • #4
        yeah that looks better.
        neil.c

        Comment

        Working...
        X