How To Program A Html List Box To Redirect To Other Web Pages For A More Professional Look

Redirection to another web page is one of the most basic and needed functions in website design. The usual way to proceed is illustrated by something like this using the HTML <a> hyperlink tag (Note: “(dot)” has been substituted for“.” and the left arrow and right arrow symbols have been replaced by the “[“ and “]” symbols, respectively to preserve formatting for viewing purposes):

<SOURCECODE>

[a href=http://www (dot) anywebsite (dot) com/anywebpage.html]Any Web Page[/a]

</SOURCECODE>

And this is fine if you are adding a small number of links to your page. But what if you have a large number of hyperlinks in the page, because you are redirected to periodical, web pages that are put out every day, week or month? Although the links would work fine, it would begin to give your web page a cluttered look. This in turn may give some site visitors the impression you are somehow unprofessional in the way you present things.

web page design

Another problem this could create is with SEO (search engine optimization). If some of the key words in your web page’s title tag are used in the URLs or anchor text of all those hyperlinks, then a large number could throw off your keyword density for the page. If it exceeds 10%, you could get red flagged by the search engines for “keyword stuffing”.

So what is a viable solution for this? I use a HTML list box to organize hyperlinks into a neat and compact format. This is the technique I use to organize my monthly technical tip publications in my “fix my computer” web page (Note: the left arrow and right arrow symbols have been replaced by the “[“ and “]” symbols, respectively to preserve formatting for viewing purposes):

<SOURCECODE>

[p]

Please select a [em]”TEKTIP”[/em] web page to view:[br]

[select size=”10″ onchange=”document.location.href=’http://www.analyzohiosoftware.com/tektip’ + this.value;”]

    [option value=”_122011.html”]December 2011[/option]

    [option value=”-012012.html”]January 2012[/option]

    [option value=”-022012.html”]February 2012[/option]

    [option value=”-032012.html”]March 2012[/option]

    [option value=”-042012.html”]April 2012[option]

    [option value=”-052012.html”]May 2012[/option]

    [option value=”-062012.html”]June 2012[/option]

    [option value=”-072012.html”]July 2012[/option]

    [option value=”-082012.html”]August 2012[/option]

    [option value=”-092012.html”]September 2012[/option]

    [option value=”-102012.html”]October 2012[/option]

    [option value=”-112012.html”]November 2012[/option]

[/select]

[/p]

</SOURCECODE>

Here’s what happens. When the site visitor clicks on an item in the list box, the “onchange” event is fired. This runs a Javascript directive called “document.location.href=’http://www.analyzohiosoftware.com/tektip’ + this.value;”. This will redirect to the web page to the right of the “=” symbol in the expression.

The web page that is redirected to must be constructed on the fly. The “http://www.analyzohiosoftware.com/tektip“ string is concatenated to the contents of  “this.value”, which represents the list box selection that is clicked by the site visitor. As an example, if the user clicks the “February 2012” selection from the list box, then the concatenated result will be: “http://www.analyzohiosoftware.com/tektip-022012.html “. The corresponding value component of “February 2012” is added to the end of the string “http://www.analyzohiosoftware.com/tektip“. Then the site visitor is redirected to “http://www.analyzohiosoftware.com/tektip-022012.html “.

Using a HTML list box to organize your hyperlinks looks nicer to your website visitors and it really does help to make a more positive first impression. In addition to my programming services, please visit my website to learn more about my computer repair services.

Pin It

Comments are closed.