ThinkStainless Posted June 2, 2006 Share Posted June 2, 2006 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 More sharing options...
vchris Posted June 2, 2006 Share Posted June 2, 2006 Look at this: http://www.alistapart.com/stories/alternate/Might help you. Link to comment Share on other sites More sharing options...
scott100 Posted June 2, 2006 Share Posted June 2, 2006 Here's quite a good one too, click the radio buttons to see it in action: http://www.dynamicdrive.com/dynamicindex9/...eetswitcher.htm Link to comment Share on other sites More sharing options...
ThinkStainless Posted June 3, 2006 Author Share Posted June 3, 2006 Thanks so much guys! the help is appreciated! Link to comment Share on other sites More sharing options...
Chocolate570 Posted June 3, 2006 Share Posted June 3, 2006 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 More sharing options...
ThinkStainless Posted June 3, 2006 Author Share Posted June 3, 2006 you rock! thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now