Jump to content

CSS layout variety


ThinkStainless

Recommended Posts

Hi, I'm in the process of developing a site using CSS. I wanted to give the user options to change between different stylesheets (click here for so-and-so layout) different views and whatnot. Just like on this site: http://csszengarden.com/I think it requires javascript, but I know barely any javascript. Does anyone know the proper code for this? Could someone help me out? Thanks!!

Link to comment
Share on other sites

I made a stylesheet switcher a while ago. I use it for forums, but you can use it with a site.Head:

<script type="text/javascript">function retriveCookie(){  cok=document.cookie;  if(cok.length <= 0);  else  {    cokStart=cok.indexOf("style=");    if(cokStart != -1)    {      cokEnd=cok.indexOf(";",cokStart);      if(cokEnd == -1)      {        cokEnd=cok.length;       }       cokFin=cok.substring(cokStart,cokEnd);       return(cokFin);    }  }}tempCok=retriveCookie().split("=");styleTemp='<link rel="stylesheet" href="'endStyleTemp='" type="text/css" />'document.write(styleTemp+tempCok[1]+endStyleTemp)for(i=0;i<document.getElementById("chanSkin").options.lenght;i++){if(document.getElementById(chanSkin).options[i].value==tempCok[1]){document.getElementById(chanSkin).selectedIndex=i}}</script><script type="text/javascript">function findSkin(){skinCh=document.getElementById("chanSkin");selOb=skinCh.options[skinCh.selectedIndex].valuedocument.cookie="style="+selObwindow.location=window.location;}</script>

Body: (change as you want, i used a select box. Just make sure the id is chanSkin)

<select id="chanSkin"><option value="firstskinurl">First Skin</option><option value="secondskinurl">Second Skin</option></select><input type="button" value="Change Skin" onclick="findSkin()" />

Hope that helps---works in most browsers, from what I checked. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...