Working with the Frameset design element

Jake Howlett, 16 July 2001

Category: Miscellaneous; Keywords: framset frame encode URL

I HATE framesets. Sorry, but I do. Nearly as much as I hate Netscape - not quite though....

Don't worry I'm not about to get in to a rant about exactly why I hate them - there is some useful information on its way. All I will say is show me a large respectable website that uses them (apart from Lotus, what do they know about usability).

The fact that I work in a team and not everybody listens to what I say means that every now and then I have to bite my tongue and just get on with using something like the frameset. That's why I have been using the R5 Frameset element for the first time this week. This proved not to be as much of a bind as I had originally thought. The only thing that caught me out was the way in which we make them dynamic. That is what I shall let you in on now.

First a simple example of what they don't tell you in the help file. Imagine you have created a two frame frameset called "main" with one frame called "left" one called "right". You want to open this frameset from a URL and tell the right hand frameset to show a particular page.

/path/to/db.nsf/main?OpenFrameSet&frame=right&src=Welcome?OpenPage

The Problem:

So we use the "frame" and "src" parameters to tell a certain frame to load a certain element. The first thing I learnt is that the second "?" can cause problems. This can confuse things by making it look like there are two Query String portions to the URL.

The Solution:

The trick is to encode the parameter before we try and append it to the URL. Here is the above URL in its URL-Encoded format:

/path/to/db.nsf/main?OpenFrameSet&frame=right&src=Welcome%3FOpenPage

Notice that the ? in the src parameter has been replaced with %3F. This shouldn't cause us any more problems.

Before we carry on let's look at a list of the URL-Encodes for some common characters:

Character URL-Encode
? %3F
& %26
% %25
= %3D
Space %20
! %21
: %3A


So if you also wanted to pass a parameter to the src page the URL would need to be:

/path/to/db.nsf/main?OpenFrameSet&frame=right&src=
Welcome%3FOpenPage%26day%3Dmonday

If you want to know the encodes of any other characters or URLs you can use this.

Taking it one step further:

The trouble with using framesets is the tendency to get carried away with yourself. With the above double frame frameset it is easy to then split the "right" frame in to another 2 frames when you realise that the right-hand frame needs a common "title" at the top. The easiest way to do this is make the "right" frame hold another frameset - a nested frameset.

In the application I was working on this did indeed happen and the design was such that we needed control over not only which frameset was launched in the "right" frame but also which page was launched in the bottom frame of the nested frameset. Sounds easy right? Not until you find out what I learnt after a little playing around with it.

Note: Using the above method you can only control one of the frames in a particular frameset using this method. You can't pass multiple frame and src parameters in the URL.


So far we have one frameset called "main" with two frames called "left" and "right". Now let's create another frameset called "mainright" that has two frames in it called "mainrighttop" and "mainrightbottom". We then want to open this "main" frameset with the "mainright" frameset in the "right" frame and (say) the Welcome page in the "mainrightbottom" frame.

image


Creating the URL:

Using the same encode principle as above the first URL I came up with was:

/path/to/db.nsf/main?OpenFrameset&frame=right&src=mainright%3FOpenFrameSet
%26frame=mainrightbottom%26src=welcome%3FOpenPage

Half of this works. The nested frameset opens but the welcome page doesn't. This is because when the above URL gets passed to the main frameset it is decoded. Here is the HTML passed to the browser:

<FRAME FRAMEBORDER=0 NORESIZE NAME="right" SRC="mainright?OpenFrameSet&frame=mainrightbottom&src=welcome?OpenPage">

What's happened here is that we have come across the same problem as we started with - the two ?s in one URL. What we need to do is encode the src parameter twice before it is passed to the nested frameset. We do this by replacing the % of the encoded parts with its own encode - %25. This gives us:

/path/to/db.nsf/main?OpenFrameset&frame=right&src=mainright%3FOpenFrameSet
%26frame=mainrightbottom%26src=welcome%253FOpenPage

The HTML passed to the browser is now exactly what we would expect to see:

<FRAME FRAMEBORDER=0 NORESIZE NAME="right" SRC="mainright?OpenFrameSet&frame=mainrightbottom&src=welcome%3FOpenPage">

This is because it has only been decoded once at this stage. This replaced the %25 with just a % and then leaves the %3F to get decoded to the ? when the page is finally opened.

Using this repeated encoding of parameters in the URL you could theoretically go down more levels of nested framesets than this. This is something I would like to think you would never catch me doing though......

Programming the URL:

If you have gotten this far in an article about an R5 feature then I presume that's what you are using. If so you can easily create these kind of URLs using the @URLEncode function. If you would rather not use an un-documented function then consider using something like this:

repl:= "?" : "&" : "=" : " " : "!" : ":";
with:= "%3F" : "%26" : "%3D" : "%20" : "%21" : "%3A";
URL:= "Welcome?OpenPage&name=jake";

@ReplaceSubstring(URL; repl; with);

If you are using a JavaScript function to create the URL then you need to use the escape() function on the URL's string object.



Note: If your Domino server is configured to allow search engines to search your Web site Domino will generate URLs with a ! instead of a ?.