Forum Moderators: not2easy

Message Too Old, No Replies

rotating style sheets

         

baldguy

6:29 pm on Apr 4, 2004 (gmt 0)

10+ Year Member



i'd like to randomly rotate my style sheets. is that possible?

tedster

6:54 pm on Apr 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure is -- it would take either javascript or some server-side script, but it's not a big deal. You could adapt most any "random rotation" script and use it to write a different stylesheet into the <head> element, instead of writing different images into the <body> element.

baldguy

7:40 pm on Apr 4, 2004 (gmt 0)

10+ Year Member



i'm not that proficient in java script, but i do have an array that i might be able to modify.

thanks.

keyplyr

7:22 am on Apr 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Beware of caching issues.

quiksan

4:15 pm on May 13, 2004 (gmt 0)

10+ Year Member



was there any progress with this?

I actually started something like this earlier, and had no success with the JS I adapted. I'd be happy to share if anyone's interested. course if someone got it working, I'd really love to see that!

thanks

Bonusbana

4:27 pm on May 13, 2004 (gmt 0)

10+ Year Member



If your host supports PHP it would be really easy:

<?php
$styles = array("style1.css","style2.css","style3.css");
$random = rand_array($styles);
$random_style = $styles[$random];
?>

<head>
<link rel="stylesheet" type="text/css" href="/path/
<?php echo $random_style;?>" />

...or something like that should do it.

BlobFisk

3:45 pm on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could adapt the A List Apart stylesheet switcher to do this. Add some randomising script to load a different sheet on page load...

HTH

ergophobe

3:19 pm on May 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just curious, but why do you want to randomly change your site look?

I understand fun changes, like the way Google dresses up for the holidays.

I understand functional changes, like offering alternate sheets to folks that don't like the default.

I'm probably just stuck in a rut, but mostly I like sites to look the same from visit to visit unless there's a reason to change. It always throws me when Brett merely changes the order for listing the forums!

Tom

quiksan

6:00 am on May 26, 2004 (gmt 0)

10+ Year Member



as for why *I'd* like to randomize the style sheets used on my site:

I've got 3 different patterns that I use for the background on my site, and the colors are distinct from one another. So each of the 3 style sheets would then display a certain pattern bg, and the corresponding colors for links, etc. just something to make it interesting w/o throwing users (completely) off.

if you want to see my site, to see what I'm talking about exactly, shoot me an email - I don't think I'm allowed to post my site on here (self promotion or something like that).

thanks for the suggestions by the way. I had actually started playing with the code from ALA and one of his linked 'friends', so was already headed in this direction.
appreciate the help tho!

Bonusbana

9:24 am on May 26, 2004 (gmt 0)

10+ Year Member



If you are extending the a list apart style switcher to select one random css on page load, remember to store a cookie as well so the user doesnt get a random stylesheet for every link he/she clicks on your page. I wouldnt stay there for long if the page looked different for every new page load.

Confused Amused

1:53 pm on May 26, 2004 (gmt 0)

10+ Year Member



Good point. If there's a different style on every page, it WILL throw the user off completely. It will probably lead to less and less traffic as a result.