[thelist] frames: I can't believe I don't know this

Ray Hill lists at prydain.com
Mon Feb 25 02:04:01 CST 2002


> so how do I make my site accessible for external links
> (so they can link to individual pages) if I use frames?

Yes, it can be done.  But it's a bit trickier than just plain HTML.

In order ot pull it off, you have to make the frames page a dynamic
page (ASP, PHP, etc).  That way, you can pass the page variable in
through the query string so the frames page loads the right page into
the content screen.  You can also pass it to whatever navigation
screens you want, so that the currently selected section is
highlighted.

Of course, there are two ways to do that.  The simple, sloppy way
would be to have the full URL passed in as the vatriable, and plug
that straight into the src attribute of the frame.  But that leaves
your site open to people plugging unwanted content into your site,
which could be potentially embarrasing (ie, your navigation/branding
with a porn site in the content area).

A better way to do it is to pass in a value that maps to a URL in the
script.  For example:

<?
switch ($page) {
  case "company_contact";
    $targetURL = "company/contact.html";
    $section = "contact";
    break;}
  case "products_foobuilder";
    $targetURL = "products/foobuilder/";
    $section = "foobuilder";
    break;
  default:
    $targetURL = "main.html";
    $section = "home";
    break;
?>

Then you just pass in the right value for $page and use the $targetURL
variable that it maps to to fill in the scr attribute in the frame.
And you can pass the $section variable to the navigation frames so
they can do their own checks to make the right nav elements selected.


--ray






More information about the thelist mailing list