FreewayTalk

31 replies to this thread. Most Recent

cosjr

17 Mar 2008, 11:07 pm

How to target iframe on a different page

Still trying to find answers to this idea. I have products scattered throughout my site that are customized in real time using a design utility on a different host. I want my customers to stay within my site when using the utility, thus I want to use an iframe.

What I want to do:

Page One - has an iframe.

Page Two - contains specific links that when clicked will open a specific web page in the iframe on page one.

Here are the instructions from a previous post on how this is accomplished on a single page, but it doesn’t seem to work across multiple pages.

The original post reads


(freewaytalk.net/thread/view/9246#m_9332):

“… what you do is create the link for each url > then press the extended button > then press new > in the name box type “target” ( without the quotes ) > then in the value box type the name of your iframe ( i.e. iframe, fred, or whatever” ) > then type ok > and ok again.”


Following these instructions causes the web page to open, but does not target inside my iframe.

This is what I am doing: 1. Create an iframe named “designer” on page 2. 2. Create a link on page one and in Edit Hyperlink dialog choose “other or http” 3. Type the full url to the page I wish to open. 4. While in the Edit Hyperlink dialog click the “extended” button 5. In extended attributes click the “new” button and name=target and value=”the name of my iframe” (in this case “designer” 6. Okay all windows. 7. When preview in browser or upload clicking the link opens the targeted website, but it doesn’t open in in my iframe.

Sorry for the long post. Anyone have insight on how to make this work?

Cecil

DeltaDave

17 Mar 2008, 11:33 pm

Can you post a link to the pages in question Cecil so that we can read the code that is being used.

In your Document settings > output make sure that HTML more readable has been selected.

David

Glasgow, Scotland

iMac 27 5K El Cap and Pro Final

cosjr

18 Mar 2008, 12:17 am

Thanks David.

This is page one which contains the link to the iframe. The link is attached to the “Blank Design” graphic.

http://abettersign.com/Designer%20Products/iframemagtest.html

The page does not open in the iframe which is at this address:

http://abettersign.com/Designer%20Products/designer.html

(Note: There appears to be two headers on the designer.html because the targeted page inside the iframe contains a header which I will delete when this gets to working properly)

Hope this makes sense. I had to upload the test page.

DeltaDave

18 Mar 2008, 12:24 am

I have had a look at this and found this thread on another Forum

http://www.dynamicdrive.com/forums/showthread.php?t=10132

Which implies that this may not be doable in just html and offers a php solution if you have php on your server.

Probably Walter is the guy that will be able to tell you for sure.

Walter are you listening?

David

Glasgow, Scotland

iMac 27 5K El Cap and Pro Final

DeltaDave

18 Mar 2008, 12:26 am

And of course you do have php I see.

Glasgow, Scotland

iMac 27 5K El Cap and Pro Final

waltd

18 Mar 2008, 1:43 pm

If you are on the same page as the iframe, you can use the target attribute to “send” links into the iframe. But from another page, you have to overload the default url of the iframe to get the same effect.

There’s two steps to this process.

One is to read the URL and decide if this process needs to happen.

The other is to change the src attribute of the iframe.

The first part is relatively simple. Add the url you want to load to the link as a querystring:

http://yoursite.com/yourframe.php?site=www.somesite.com

If you need to have slashes or other “special” characters in there, you must url-encode them. Nothing path-like is allowed to the right of the question mark in the URL.

If you want to load a page within your site, then it could be as easy as adding the filename of that page in the same manner:

http://yoursite.com/yourframe.php?page=somepage.html

So in Freeway, on your iframe page, do the following:

Change the filename extension to .php

Open the Page > HTML Markup dialog, and enter the following block of code into the Before HTML section:

<?php
$src = 'your_default_page.html';
function clean($string){
    return trim(strip_tags(urldecode($string)));
}
if(isset($_GET['page'])){
    $src = './' . clean($_GET['page']);
elseif(isset($_GET['site'])){
    $src = 'http://' . clean($_GET['site']);
}
?>

Make sure that you change the placeholder ‘your_default_page.html’ to be the filename of the page you want to load if there is nothing in the querystring.

Now, click on your iframe, and in the Actions palette, change the URL from whatever it is currently to this:

<?=$src?>

Preview the page into a text editor, and confirm that Freeway (or the Action) did not change any of the angled brackets into < escape sequences.

Now, upload your site again. You will not be able to test this except on a real PHP Web server.

When nothing is in the querystring portion of the URL, the default page should load. If there is a variable called site or page, then it should load. All of this will follow the usual rules of Web server security, so you won’t have to worry about someone entering ‘page=../../../etc/passwd’ into their browser’s navigation bar. Only files that Apache has access to will be served by this trick. You will have to worry about people entering ‘site=www.whitehouse.com’ in there and getting your page framing a porn site, though. There’s a way to work around that, but it basically consists of making a “whitelist” of approved sites, and then using an array to choose which one to load. It’s more work, and less clear for a first-time programmer, so hopefully this will be a good start for you.

Walter

On Mar 17, 2008, at 8:24 PM, DeltaDave wrote:

I have had a look at this and found this thread on another Forum

http://www.dynamicdrive.com/forums/showthread.php?t=10132

Which implies that this may not be doable in just html and offers a php solution if you have php on your server.

Probably Walter is the guy that will be able to tell you for sure.

Walter are you listening?

David

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

18 Mar 2008, 1:55 pm

Thank you David and Walter.

David, I read the linked article and it was a bit above my knowledge, however it enticed me to research on the web and I believe I have an understanding of what you propose. Just didn’t know how to implement in Freeway.

Alas, here’s Walter to the rescue with just such research I found on the web.

I will follow your recommendations later when time permits and report back.

Cecil

cosjr

26 Mar 2008, 11:13 am

Walter,

I’m struggling to get this. I have created a test site. Maybe you can give some explanation of where I’ve messed up and help other also.

On the test site I’ve included a link to download the Freeway file for the test.

http://cecilsellers.com/test_iframe/

Thank you for your valuable time.

Cecil

waltd

27 Mar 2008, 1:25 pm

You left out the PHP code from the Before HTML block of the iframe page that would set up the value of $src. Right now, your iFrame is trying to load nothing. If error reporting was turned on on your server, you would see an error saying that $src is not set.

If you look up this thread, you will see this block of code:

<?php
$src = 'your_default_page.html';
function clean($string){
    return trim(strip_tags(urldecode($string)));
}
if(isset($_GET['page'])){
    $src = './' . clean($_GET['page']);
elseif(isset($_GET['site'])){
    $src = 'http://' . clean($_GET['site']);
}
?>

Paste that into your Page: HTML Markup: Before HTML dialog and publish again. Once you have that in place, this page should work correctly.

Walter

On Mar 26, 2008, at 7:13 AM, cosjr wrote:

Walter,

I’m struggling to get this. I have created a test site. Maybe you can give some explanation of where I’ve messed up and help other also.

On the test site I’ve included a link to download the Freeway file for the test.

http://cecilsellers.com/test_iframe/

Thank you for your valuable time.

Cecil

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

27 Mar 2008, 4:05 pm

Sorry Walter. I had that entered in a million times. Must have deleted it somehow.

I’ve now entered the code like this:

<?php
$src = 'http://www.google.com/';
function clean($string){
return trim(strip_tags(urldecode($string)));
}
if(isset($_GET['page'])){
$src = './' . clean($_GET['page']);
elseif(isset($_GET['site'])){
$src = 'http://' . clean($_GET['site']);
}
?>

gives a 404 error page.

I must be still missing something.

waltd

27 Mar 2008, 4:30 pm

Try adding a curly bracket to the left of the elseif : }elseif(…

I don’t know why that is missing, but that’s where the problem is starting from.

Walter

On Mar 27, 2008, at 12:05 PM, cosjr wrote:

Sorry Walter. I had that entered in a million times. Must have deleted it somehow.

I’ve now entered the code like this:

<?php > $src = 'http://www.google.com/'; > function clean($string){ > return trim(strip_tags(urldecode($string))); > } > if(isset($_GET['page'])){ > $src = './' . clean($_GET['page']); > elseif(isset($_GET['site'])){ > $src = 'http://' . clean($_GET['site']); > } > ?>

gives a 404 error page.

I must be still missing something.

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

27 Mar 2008, 4:43 pm

Thanks Walter.

Now iframe page will load with the default Google site in the iframe. However, the link page link still gives an error 404 when click on.

cosjr

27 Mar 2008, 4:45 pm

Actually, I’m thinking this might be because the link extended doesn’t have http://www before the entry?

cosjr

28 Mar 2008, 1:00 am

Thank you Walter. Finally. I have it working. I learned my mistake by paying close attention to what was in the url on the error page.

Your example:

yoursite.com/yourframe.php?site=www.somesite.com

I simply left off the “yoursite.com/” and all is well. So the corrected working link in the example is now:

iframepage.php?site=www.apple.com

Thank you so very much. I hope this helps others along the way.

cosjr

29 Mar 2008, 11:50 am

So, now I have a further how-to-do-this question.

Scenario: When clicking the link on the link page the correct url is loaded in the iframe on another page. Good, but as Walter explained earlier, there are some security issues. Also, I’d rather not have the full url showing in the address bar at all. When you add a link on the same page as the iframe using the extended attribute “target=iframename” the url in the address bar displays only the page that contains the iframe and not the iframe target url. That is what I prefer.

So, I’m thinking why not put some kind of container link on the same page as the iframe with a dynamic call that captures the link url on the link page and passes it off to the iframe much the same way as you’ve done with the html markup.

By doing this can we overcome the security issue and hide the target url? I’m also thinking if this method would allow the original link to not be url encoded. (I will have lots of links on many pages and translating is a pain).

Probably not possible, huh?

Cecil

waltd

29 Mar 2008, 1:43 pm

On Mar 29, 2008, at 7:50 AM, cosjr wrote:

So, now I have a further how-to-do-this question.

Scenario: When clicking the link on the link page the correct url is loaded in the iframe on another page. Good, but as Walter explained earlier, there are some security issues. Also, I’d rather not have the full url showing in the address bar at all. When you add a link on the same page as the iframe using the extended attribute “target=iframename” the url in the address bar displays only the page that contains the iframe and not the iframe target url. That is what I prefer.

So, I’m thinking why not put some kind of container link on the same page as the iframe with a dynamic call that captures the link url on the link page and passes it off to the iframe much the same way as you’ve done with the html markup.

There’s a chicken-or-egg problem here. How will you encode the link that you pass to the “container” link? You are going to have to put the URL that you want to load into the iframe somewhere.

By doing this can we overcome the security issue and hide the target url? I’m also thinking if this method would allow the original link to not be url encoded. (I will have lots of links on many pages and translating is a pain).

The only security issue (which is solved in the code example I posted) would be if you allowed any old file to be included using PHP. PHP runs as the same user as the web server, and it has read access to much of the server’s filesystem (above and beyond the Web root). If your code function was using include() or require() to merge another file into the current page, then your page could be tricked into loading ../../../../etc/passwd into that same space. But you’re using an iframe, and the usual rules of the Web server apply. Nothing awful can happen here, unless your server administrator has been hitting the bottle or something.

What you have here is a curiosity issue more or less. Oooh! Look what happens if you put in www.pr0nsite.com after the URL! Look, Ma! I hAx0red the server!

If you really want to get around this issue, it’s going to be more work, not less. What I would do is stash all of the sites you want to load in a single PHP array:

$sites = array(
    'www.apple.com',
    'www.softpress.com',
    'www.google.com',
    'www.somesite.com'
    );

Then on your page where you want to create your link, you would use this notation:

<a href="myframepage.php?site=0">Apple</a>

(Arrays start with the index 0, so the first item is 0 and the last item is [number of items] -1.)

On your frame page, you would change the script to read like this:

if(is_numeric($_GET['site'])){
    $site = (isset($sites[$_GET['site']]) ?
        $sites[$_GET['site']] : $sites[0];
    $src = 'http://' . $site;
}

That block would interpret the incoming index number (which is very secure since it means nothing to the visitor) and then translate that to the proper site. There’s a check step in there to see if the index is valid, and if not, the first item on your list is loaded. This technique is known as a whitelist, since only sites on your approved list can be loaded at all.

Back on your other pages, you simply have to keep track of the index numbers of the various sites, but you won’t have to url-encode anything when you make a link.

Walter

Probably not possible, huh?

Cecil

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

1 Apr 2008, 10:36 am

What you have here is a curiosity issue more or less. Oooh! Look what happens if you put in www.pr0nsite.com after the URL! Look, Ma! I hAx0red the server!

If you really want to get around this issue, it’s going to be more work, not less.

Okay. I don’t care how others get their jollies, so will ignore this issue.

Do have a question about this:

The first part is relatively simple. Add the url you want to load to the link as a querystring:

http://yoursite.com/yourframe.php?site=www.somesite.com

If you need to have slashes or other “special” characters in there, you must url-encode them. Nothing path-like is allowed to the right of the question mark in the URL.

All the links I want to use have slashes. After the question mark (?site=www.somesite.com) needs to be url-encoded? Researching that term I came across a few sites that will return a url-encode if you type in a normal url. Is that what this means? When I try that and paste the result after the ?site= I get an error when published.

For example this would be my link for a site without slashes or other special characters: iframepage.php?site=www.apple.com

But if my url contained a slash it would look like this: iframepage.php?site=www.apple.com/itunes/

So therefore, I need to encode www.apple.com/itunes/ Using a url-encode site I get this: www.apple.com%2Fitunes%2F

But, this doesn’t work in my test. The apple.com home page loads instead of the itunes page. So I guess my encode is incorrect?

Cecil

waltd

1 Apr 2008, 1:29 pm

On Apr 1, 2008, at 6:36 AM, cosjr wrote:

What you have here is a curiosity issue more or less. Oooh! Look what happens if you put in www.pr0nsite.com after the URL! Look, Ma! I hAx0red the server!

If you really want to get around this issue, it’s going to be more work, not less.

Okay. I don’t care how others get their jollies, so will ignore this issue.

Do have a question about this:

> So therefore, I need to encode www.apple.com/itunes/ Using a url-encode site I get this: www.apple.com%2Fitunes%2F

But, this doesn’t work in my test. The apple.com home page loads instead of the itunes page. So I guess my encode is incorrect?

Cecil

There are two levels of url-encoding possible in PHP. One is regular urlencode(), which would not replace the slashes as your example did, but would replace spaces with a + and ampersands with & and a few other special characters with their entity escapes. The next level is called rawurlencode() and is what your encoding service is showing you. Everything that isn’t a-Z,0-9 is escaped.

Now most web servers will automatically undo urlencode() (the equivalent in PHP would be to explicitly run urldecode() against the input). But none will do the reverse of rawurlencode(). You can simply apply it to your input by using the PHP function rawurldecode () in your processing function. Modify the clean() function to use rawurldecode instead of plain urldecode and you will be all set.

function clean($string){
    return trim(strip_tags(rawurldecode($string)));
}

Walter

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

7 Apr 2008, 2:57 pm

Modify the clean() function to use rawurldecode instead of plain urldecode and you will be all set.

function clean($string){ return trim(strip_tags(rawurldecode($string))); }

Thanks Walter. This works, but has introduced a new unexpected problem. My crazy long url link is causing a problem. It is best for you to see the problem as explained on the test page:

http://cecilsellers.com/test_iframe/link_page.html

I would also love to find a way to not show that full url address in the address bar so that only my page that contains the iframe would show and not the target url of the iframe. Any ideas here also? Would a javascript function serve that purpose?

waltd

7 Apr 2008, 3:06 pm

That’s easy to fix. The issue is that you have not made a valid querystring to the inner page. If you look at the red text, you will see that you have abettersign/index.php&cpi — that needs to be abettersign/index.php?cpi. The question mark as the first thing after the index.php is mandatory if you are trying to pass variables to your server. The fact that the same link is loading correctly into a new window is due to your browser correcting the mistake silently. (In other words, you are not requesting a valid URI from the server, so your browser helps out and fixes it for you, converting that first & to a ? when the request fails the first time.) When you are requesting the page through PHP, no such magic is going on behind the scenes.

Walter

On Apr 7, 2008, at 10:57 AM, cosjr wrote:

Thanks Walter. This works, but has introduced a new unexpected problem. My crazy long url link is causing a problem. It is best for you to see the problem as explained on the test page:

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

7 Apr 2008, 3:18 pm

Wow, Walter, that was fast. I made the change as suggested, but doesn’t work. I’ve spelled out the change on the page again:

http://cecilsellers.com/test_iframe/link_page.html

Perhaps I have it incorrect.

waltd

7 Apr 2008, 8:41 pm

You need to take your entire ‘site’ parameter and rawurlencode it. Right now, you have the syntax correct as far as it goes, but unless you rawurlencode it, your parameter is being cut off at the very first &. That’s because PHP has no way to distinguish between the ampersands within your site variable’s value and the ampersands that would be used to add additional variables beyond the site variable in your page’s own querystring.

site=designer.realtimedesigner.com/abettersign/index.php?cpi=1246&cti=104
//should be:
site=designer.realtimedesigner.com%2Fabettersign%2Findex.php%3Fcpi%3D1246%26cti%3D104

Walter

On Apr 7, 2008, at 11:18 AM, cosjr wrote:

Wow, Walter, that was fast. I made the change as suggested, but doesn’t work. I’ve spelled out the change on the page again:

http://cecilsellers.com/test_iframe/link_page.html

Perhaps I have it incorrect.

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

7 Apr 2008, 9:05 pm

On 7 Apr. 2008, 8:41 pm, waltd wrote:

You need to take your entire ‘site’ parameter and rawurlencode it. Right now, you have the syntax correct as far as it goes, but unless you rawurlencode it, your parameter is being cut off at the very first &. That’s because PHP has no way to distinguish between the ampersands within your site variable’s value and the ampersands that would be used to add additional variables beyond the site variable in your page’s own querystring.

site=designer.realtimedesigner.com/abettersign/index.php?cpi=1246&cti=104 //should be: site=designer.realtimedesigner.com%2Fabettersign%2Findex.php%3Fcpi%3D1246%26cti%3D104

I’ve added this bit also to the example page. Still get the same results. The “index.php?cpi=1246&cti=104” which is now “index.php%3Fcpi%3D1246%26cti%3D104” is not loading correctly, although that part appears in the address bar. I should still be using rawurldecode in the code before html on iframe page, correct?

waltd

7 Apr 2008, 9:17 pm

It appears to be working, it just doesn’t fit. Try making your iframe wider, and set its height to much taller. You could also try enabling scrolling for your iframe, which would (partially) solve the height issue.

Walter

On Apr 7, 2008, at 5:05 PM, cosjr wrote:

On 7 Apr. 2008, 8:41 pm, waltd wrote:

You need to take your entire ‘site’ parameter and rawurlencode it. Right now, you have the syntax correct as far as it goes, but unless you rawurlencode it, your parameter is being cut off at the very first &. That’s because PHP has no way to distinguish between the ampersands within your site variable’s value and the ampersands that would be used to add additional variables beyond the site variable in your page’s own querystring.

site=designer.realtimedesigner.com/abettersign/index.php? cpi=1246&cti=104 //should be: site=designer.realtimedesigner.com%2Fabettersign%2Findex.php%3Fcpi %3D1246%26cti%3D104

I’ve added this bit also to the example page. Still get the same results. The “index.php?cpi=1246&cti=104” which is now “index.php% 3Fcpi%3D1246%26cti%3D104” is not loading correctly, although that part appears in the address bar. I should still be using rawurldecode in the code before html on iframe page, correct?

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

7 Apr 2008, 9:45 pm

On 7 Apr. 2008, 9:17 pm, waltd wrote:

It appears to be working, it just doesn’t fit.

Actually, that’s the point. It APPEARS to be working. It is working to load part of the URL. What you are seeing is the default load of “designer.realtimedesigner.com/abettersign/”.

The way I know this is because the small java graphic thing that says “Start Designing” is on the default page for my site. If the rest of the url loaded that part wouldn’t be there and there would be other text items loaded. You can see the proper example of this in the third test link “Click this link” down the page. The remaining part of the url “index.php?cpi=1246&cti=104” isn’t getting loaded.

Thank you for being patient with this.

waltd

8 Apr 2008, 12:45 am

When I enter <http://designer.realtimedesigner.com/abettersign/ index.php?cpi=1246&cti=104> in a browser, I see the exact same thing as when I see it called out in the iframe. But if I enter http://designer.realtimedesigner.com/abettersign/index.php&cpi=1246&cti=104 in the browser, I see the example text for a magnet. Which is totally wacked out. The former is a valid URL, and the latter is not, but the invalid URL works.

Okay, new plan:

<site=designer.realtimedesigner.com%2Fabettersign%2Findex.php%3Dcpi% 3D1246%26cti%3D104>

goes in the URL, substituting %3D for %3C.

This should work. Really. Otherwise, it will be time to call these folk and tell them that their page is broken. (Which it certainly is.)

Walter

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

8 Apr 2008, 10:45 am

Walter, when you enter

designer.realtimedesigner.com/abettersign/index.php&cpi=1246&cti=104

in the browser it is exactly what I want you to see. The text example for a magnet. It is supposed to look that way. That is the URL I want to load, not the other called out in the iframe.

Here is a jpg version, in case we aren’t seeing the same thing. http://cecilsellers.com/tests/stuff/page_to_show_magnet.jpg

I know this post is getting long and your time is valuable. It wouldn’t be so difficult if the url was simpler. Thank you.

waltd

8 Apr 2008, 12:29 pm

Did you get my last post? I pointed out that when you enter an INVALID, BROKEN URL, it works perfectly. And when you enter a correctly-formed URL, it does not. There is clearly something wrong with the page on realtimedesigner, it is not properly decoding the querystring.

Walter

On Apr 8, 2008, at 6:45 AM, cosjr wrote:

Walter, when you enter

designer.realtimedesigner.com/abettersign/index.php&cpi=1246&cti=104

in the browser it is exactly what I want you to see. The text example for a magnet. It is supposed to look that way. That is the URL I want to load, not the other called out in the iframe.

Here is a jpg version, in case we aren’t seeing the same thing. http://cecilsellers.com/tests/stuff/page_to_show_magnet.jpg

I know this post is getting long and your time is valuable. It wouldn’t be so difficult if the url was simpler. Thank you.

Freeway user since 1997

http://www.walterdavisstudio.com

cosjr

8 Apr 2008, 12:44 pm

Okay. Yes, that is clear to me now. Sorry. I will contact them about it. Thanks for all your help. How do donate to your cause?

waltd

8 Apr 2008, 1:17 pm

There’s a donate button on my Actions repository: http://freewaypro.com/actions/downloads

Thanks in advance if you do donate, but you’re welcome in any case.

Walter

On Apr 8, 2008, at 8:44 AM, cosjr wrote:

Okay. Yes, that is clear to me now. Sorry. I will contact them about it. Thanks for all your help. How do donate to your cause?

Freeway user since 1997

http://www.walterdavisstudio.com

Sunny Sawrav

1 Apr 2011, 11:41 am

Hi there, I was going through the thread and have a similar problem. Please help.

http://www.motherjane.in/index2.html

Now, I need to send out a url that when clicked on, opens the motherjane.in/index2.html with motherjane.in/band in the iframe ‘body’.

Please help.

Sunny

Back to Top

waltd

1 Apr 2011, 7:48 pm

There’s two ways to handle this. One is to have your frameset page be written in PHP or another server-side language, and pass a variable to it in the request, so your frameset knows which page to load into the frame or frames. The other is to do the same thing, except with JavaScript. This second method has all sorts of down-sides, so I don’t recommend it as highly as the PHP.

In either case, your URLs that you use to load the frameset + non-default page would look nearly the same:

http://example.com/frameset.php?frame1=somepage.html
or
http://example.com/frameset.html?frame1=somepage.html

Here’s how to build the PHP one. (I assume, with some degree of certainty, that your server supports PHP. Most do.)

You’ve already built a frameset in Freeway. So you have the local equivalent of frameset.html already. If you were to look inside the source code for this file, you would find that it doesn’t have all that much inside it, just references to other pages and some instructions for how to assemble the composite page.

What you need to do is translate the automatic URLs that Freeway has made for you into references to programming variables. Let’s keep this simple, and say that you’ve got a basic top-banner, bottom-stretchy-area style frameset, and you’re only interested in loading the content into the bottom frame. The top frame will always be the same.

Open up your Frames palette, and double-click on the bottom frame there. You will see a dialog very similar to the Hyperlink dialog, where you may choose which page will load into that frame by default. Click over to the External tab, and enter the following:

<?php echo $frame_src; ?>

Okay out of the dialog. Your bottom frame will have disappeared, replaced by some text indicating the URL. At this point, you should also use the Page Inspector to change the filename of your frameset from frameset.html to frameset.php. This will not change the Title of your page, only the Filename.

Now open the Page / HTML Markup dialog on the frameset page and move to the Before HTML section. Enter the following code there:

<?php 
$frame_src = 'your_default_page.html';
if(isset($_GET['frame1'])){
    if(file_exists(dirname(__FILE__) . '/' . $_GET['frame1'])){
        $frame_src = $_GET['frame1'];
    }
}
?>

Now you cannot preview this frameset locally any more, you will have to upload it to your server to see anything, because PHP requires the server to read and interpret the instructions before sending HTML to your browser.

To use this, you would simply create URLs that include the filename of the page you want to load into the bottom frame (and you’d have to make sure that page is in the same folder as the frameset file itself — there’s a strong security measure in the code above, meant to keep someone from viewing http://example.com/frameset.php?frame1=/etc/passwd or something equally embarrassing. You’ll have to enter those URLs manually, using the External tab of the Hyperlink palette.

Let us know how it goes, if this works or not.

Walter

Freeway user since 1997

http://www.walterdavisstudio.com