View Full Version : Random Stylesheet Type question

12-12-2005, 02:36 PM
Hi Guys

I'm working on my companies website at the moment. I've been making sites for a while, but I've never gotten into CSS style sheets or any real coding stuff. Basically, I want to have maybe 3 different coloured versions of the site, with a different picture for each, and have it so that when you visit the site you randomly see one of the 3. They'll be identical apart from the colour scheme and picture. You can view the site here:


If anyone knows how to code a simple index.htm page that will randomly direct you to, say, index_green.htm, index_red.htm or index_blue.htm I'd be forever grateful. I've read on some of the posts here that CSS is the way to go but I really haven't a clue where to start.



12-12-2005, 02:54 PM
Are you able to use PHP on your server?

If so, you could solve the problem through a little PHP command.


$css = rand(0, 2);

if($css === 0){
echo '<link rel="stylesheet" type="text/css" href="/sylesheet1.css" />';

elseif($css === 1){
echo '<link rel="stylesheet" type="text/css" href="/sylesheet2.css" />';

echo '<link rel="stylesheet" type="text/css" href="/sylesheet1.css" />';


Replace the 'href' bit with a link to whatever stylesheet you are using and place the above code inside the <head> tags of your website.

I hope that works, it seemed to when I tested it.

PS Sorry if that shouldn't have been posted in this forum. :eek: