FrontPage Tips by Ward Cameron Enterprises
Take Your Web Site to New Levels
Redirecting Users to New Pages
Occasionally, you'll find that you need to redirect users to a
page that they may not have planned. For instance, you may want to
have them directed to a page.
This page uses a few advanced techniques discussed in our tutorials
called Database Results
Basics AND
Passing Parameters
Using a Page Redirect
Websites often have changing content, and pages sometimes are moved.
Since the moved pages may have been indexed by search engines, you will be
leaving your visitors with the dreaded Page Not Found Error.
As a better option, keep the original link active but put some simple
code on the page that will redirect your users to the new page location.
Your redirect code will need to be placed above the first HTML tag in
the FrontPage HTML tab. Type the following code:
<%@ language="JScript"> %>
<%
Response.Buffer = true;
Response.Redirect( "http://www.FrontPageMagic.com" );
%>
In this case, the browser would be redirected to FrontPageMagic.com.
Redirecting a Page Using a Parameter
In a database driven site, you may want to present your users with a
list of websites in a drop-down list and give them the option to go
directly to one of the sites. To do this, you'll need to create two pages,
one to display the form, and a second one to receive the link code and
redirect to the appropriate page.
In this example, we'll pass the website URL as a parameter. For
example, in this case, the URL will be passed at the end of the hyperlink
as in the following example:
http://www.FrontPageMagic.com/redirect.asp?Website=http://www.WardCameron.com
First, let's create the redirect page. In order to have the page
redirect to a website that is contained within a parameter, you need to
alter the code slightly. Like the first example, the code needs to be
placed above the first HTML tag on a black web page.
<%@ language="JScript"> %>
<%
Response.Buffer = true;
var Website = Request.QueryString( "Website");
Response.Redirect( Website );
%>
This will instantly redirect the page to the target link that is passed
either through a hyperlink OR through a form.
For this example, we've created a simple database table with two
fields, Description and Website. The following drop-down box displays the
text from the Description field and then submits the Website field to
URLRedirectResults.asp.
In this example, I've inserted a simple Database Results Wizard (DRW)
which displays the list of site descriptions and websites.
Now, to create a link to the redirect page, I've selected the
SiteDescription field and then set the link to send the page to
URLRedirectResults.asp. Then, I clicked on the parameters button to add
the Website parameter to the link. This will then add the website address
to the end of the url.
When the URLRedirectResponse.asp page receives the page it will then
send the visitor to the requested page.
You can also use a form to accomplish the same thing. On a blank page,
insert a blank form. Inside the form, insert a DRW that displays the
SiteDescription, but passes the Website address to the next page. Right
click on the form and select properties. Choose Send To Other and then
properties. In the Action field type URLRedirectResponse.asp and under
Method select Get. This will append the Website parameter to the end of
the URL as in the first example.
Why not give it a try here.
All it takes is a little FrontPage Magic.
Super Redirect - Redirect With A Parameter to one of several pages
based upon data in several tables
OK, here's the situation. In MountainNature.com, I had three tables,
one with data on plants, another on birds and a third on wildlife. I also
had three database pages that display data from the tables is part of an
online field guide. Since the information you track is different for each,
it makes sense to have the data in different tables.
I wanted to offer uses a quick species finder search page. First they
would select plants, animals or birds from a drop-down box. If they
selected plants, this would open a second drop-down box that would list
all of the plants with both common and Latin names sorted in a list.
Selecting one of them would open a page that would display the results.
For this to work, I needed to do three things:
- First, I needed to pass a parameter that would contain the
table parameter. Along with this, it would pass the direction of
the target page. All that would be missing would be the ID tag for
the particular species.
- When they selected the name on the second drop-down box, it
would provide the missing ID tag.
- Finally, I needed a redirect page that would accept the link
address, add the ID tag to the end of the address and then
redirect to the correct page for displaying plant data.
Check it out here
This took a great deal of planning to execute. In order to illustrate
the technique, we'll do the same thing using the Northwind database. In
our case, we'll create the option to select from either customers or
suppliers, and then open a page that displays the appropriate results.
These tutorials are part of an upcoming training course called
"FrontPage Magic - How To Create A Database Driven Website For
Non-Programmers". Stay tuned for more details on this exciting new
product.
Send your tips to .
All materials Copyright
© Ward Cameron All Rights Reserved