[an error occurred while processing this directive]

"Excuse me please. My ear is full of milk..."

– Oliver Hardy, Going Bye Bye (1934)

Skip on down to the menu.

Style Switcher Perl Script

Here's a style switcher script that does two things.

  1. The first thing it can do is insert external style sheet link elements, or any other html for that matter, based on the value of a cookie.
  2. The second thing it can do is set the value of this cookie based on input you give it on the url you use to call the script.

You can see where this is going... Custom html based on a user cookie, and the ability for the user to alter this cookie by clicking links!

The page you're reading now is using the very code shown below.

You may be tempted to alter this program to include an arbitrary style sheet specified by the user, rather than one of a few that are defined in the program. Don't do it. You want to be completely in control of which style sheets the user can use, as well as the content of those style sheets. Remember, Internet Explorer can execute ActiveX code that is buried in css!

How to include

Using Apache SSI

Use the following line in your .shtml files wherever you want the menu to appear.

Since I use only Apache I don't have any idea how this would work on any other web server. Sorry...

Invoking the script to include a style sheet selection

<!--#exec cgi="/cgi-bin/styleswitcher.pl"-->

You may need to adjust the path as required by your web server setup.

Invoking the script to switch the style sheet selection

<!--#exec cgi="/cgi-bin/styleswitcher.pl?style=Cookie+Value"-->

In the example above the value of the cookie that I'm setting is "Cookie Value". This is case sensitive. The "+" is required to indicate that there is a space. Remember, officially there can never be a space in a url, so this is the cgi way to indicate a space.

After the cookie is set to the new value, the current page will reload. This will refresh the page with the new style sheet links.

The Code

In the example below, the cookie name I use is "style". The two valid values for this cookie are "Lefthand Menu" and "Righthand Menu".

You'll have to modify this to meet your own requirements. As I make refinements to the script, I'll try to put all the custom config stuff at the top of the file.

[an error occurred while processing this directive]