logo

Working with the Frameset design element


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 ?.

Feedback

  1. a step deeper

    Your piece today on frameset URLs is timely...if I may I'd like to ask a question or two.

    Once you have encoded the URL to open specific elements of a frame, how could one pass specific arguments to the specified frameset elements, i.e. could this method be used to pass search criteria to a $$SearchResults template in a frameset? If not, do I need to go the javascript route (with which I am not completely fluent) to extract the query_string information in order to populate the search results?

    1. Re: a step deeper

      Glad the article has helped somebody out in its first day ;)

      You can add the parameters you want to send to the element using the same method. To open a search view and pass it the query you could use: [<span style="color:#660000;">] /path/to/db.nsf/main?OpenFrameset&frame=right&src=mainright%3FOpenFrameSet %26frame=mainrightbottom%26src=search%253FOpenView%2526Query%253Dfind%2520me%252 6Count%253D10 [</span>] So [<b>all</b>] the special characters have been double-encoded.

      HTH Jake

  2. ..more tips

    you can cut out the guess work and the replacesubstring by using the undocumented @UrlEncode formul: there are two types of output one is "Domino" which outputs in the domino format and the other UTF-8 format (Web friendly). here's an example..

    start:="/path/to/db.nsf/main?OpenFrameSet"; frame:=@URLEncode("";"&frame=right"); src:=@URLEncode("";"&src=Welcome?OpenPage"); start+frame+src

    the result is:

    /path/to/db.nsf/main?OpenFrameSet%26frame%3Dright%26src%3DWelcome%3FOpenPage

    1. Re: ..more tips

      What are the parameters @URLEncode accepts?

      Show the rest of this thread

  3. ...but does it work with a Notes client URL?

    These are great examples and informaiton you cannot find in the Designer help. But when I tried to encode the above for a notes client link it doesn work? Any Ideas?

    For example, this doesnt work: notes://scilkl2ns/MyDatabase.nsf/Main?OpenFrameSet&frame=Body&src=(Training%20-% 20All%20Requests)?OpenView

    But This Does: http://www.summitholdings.com/MyDatabase.nsf/Main?OpenFrameSet&frame=Body&src=(T raining%20-%20All%20Requests)?OpenView

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Miscellaneous"

« Previous Article Next Article »
Display responses on every page   Which browser am I using? No comment!

About This Article

Author: Jake Howlett
Category: Miscellaneous
Keywords: framset; frame; encode; URL;

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »