who framed me? Frames did!

  • Started
  • Last post
  • 3 Responses
  • History

    Listen compadres,

    Some people have linked to certain pages on my site. Problem is, they are supposed to be an iframe now as part of a larger page. I think it is possible to automatically load that larger page with the frame in it, when somebody accesses the frame by itself. How do you do that? Any reference page or tutorial would be good too. Gracias!

  • jevad0

    stick this bit of jscript:

    if (window == top)
    {
    top.location.href = "yourpage.html";
    }

    in all the pages you don;t want to be linked to out of your frameset.

  • History0

    that's it?

    geez that's simple. when i look at it i should have thought of it myself.

    thank you jevad

  • CAJTBr0

    only problems with that are:

    1) if someone includes your page as part of their frameset, the script won't fire.

    2) say you have 3 pages that load into the iframe, and put that code into each of them, when the script fires from pages 2 or 3, it's going to reload the container page with the iframe as page 1 (the default page).

    if you're bothered about that, you can get around both problems.

    get around the first one by using an if top.location.href != (or similar) rather than the if window == top.

    you can get round the second by passing the name of the page that's firing the script to the top frame in a query string, and having it automatically load the iframe as the file specified in the query string (if the query string isn't empty).