WillMaster Possibillites Logo EzineSeek Award
Classic Browser Redirection
by
William Bontrager

Permission is granted to reprint the article below in its entirety provided no changes are made to the article text and the author's name, signature lines, and copyright line are printed with the article. However, you may change the article's title.

Many websites have them. You select a destination (usually from a drop-down list box) and click a button.

Off you go!

You can do it with JavaScript. And you can do it with CGI.

JavaScript is probably the easiest to implement. However, only JavaScript enabled browsers can use it.

CGI can be used with any browser. However, you must have a CGI enabled website to implement it.

This article presents both.

Note: This article contains both JavaScript and HTML code. Some email programs introduce extraneous JavaScript-corrupting line breaks. If you are reading this on an HTML-enabled email program, you may need to "view source" for all the code to be visible. To be sure you get the original, view this article in the archives -- it will present the code correctly in your browser. See http://willmaster.com/possibilities/archives/

There are two installation steps:

STEP ONE:

~~ CGI Method

Obtain and install the "Drop Menu" program from The Caesium Network at http://www.skirrow.com/home/Scripts/scripts/dropmenu.shtml The README file contains simple instructions; except it leaves out one important item. The first line of the Perl script must point to the location of Perl on your system -- probably

#!/usr/bin/perl
or
#!/usr/local/bin/perl

~~ JavaScript Method

Insert the following JavaScript code between the <head> and </head> tags of your HTML page:


<script language="JavaScript"><!-- 
function redirect(){
var loc = document.gourl.newurl.selectedIndex;
var url = document.gourl.newurl.options[loc].value;
window.location.href = url;
} //-->
</script>

STEP TWO:

The HTML code for the drop-down list box is almost the same for both methods. (The two differences are in the <form... and <input... tags.) Place the code wherever you want the list-box to appear on your page.


<form method="POST" action="http://www.yourdomain.com/cgi-bin/drop.pl>
<select name="newurl">
<option value="">-- Select Destination --
<option value="http://willmaster.com/">WillMaster.com
<option value="feedback.html">Contact Us
</select>
<input type="submit" value="Go!">
</form>


<form name="gourl">
<select name="newurl">
<option value="">-- Select Destination --
<option value="http://willmaster.com/">WillMaster.com
<option value="feedback.html">Contact Us
</select>
<input type="button" value="Go!" onClick="javascript:redirect()">
</form>

Each of the above has two selections for the list box, "http://willmaster.com/" and "feedback.html". Replace those with your own URLs and labels. Add as many as you want. The only limit is the tolerance level of your visitors.

Happy year MM and beyond!

Copyright 1999 by William Bontrager

William Bontrager, Programmer and Publisher
"Screaming Hot CGI" programs
"WillMaster Possibilities" e-Newsletter
http://willmaster.com/possibilities/
subscribe-possibilities@willmaster.com