You'd need JavaScript and some server side code to do this. (Well, you could duplicate the server side functionality is client side code, but that would be bad.)

First you need to detect if the page has been loaded outside the frameset. Check top.location with a regular expression to ensure it matches http://www.example.com/ (or whatever the URL of your frameset is) with either nothing following it, or just a query string.

If it fails the check you need to (still with JavaScript) set top.location to http://www.example.com/ but append a query string which includes a means to identify the URL of the page the user visited - the URL itself is a good choice. Make sure you URL encode it!

Then you need to dynamically generate your frameset. Check the query string. If no URL is included, then show the default page. If there is a URL then check that it belongs to you (this protects against pishing attacks) and then set the src attribute of the <frame> to match.

Of course this will still fail if JavaScript is not available, and you will probably annoy users who want to view a page outside your frameset, and its quite a lot of work - so you'd probably be better off just ditching the frames in favour of something less painful.


In reply to Re: OT- HTML Page and Frame Question by dorward
in thread OT- HTML Page and Frame Question by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.