Results 1 to 2 of 2

Thread: Need a cookie to set selected css?

  1. #1
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need a cookie to set selected css?

    Hi all,
    I've just launched a new design for our site and have one last thing I'm having trouble with.... I have 5 css styles users can switch to via javascript links that changes the site's color scheme. It works great except I need it to stick via cookie so the selected css is used page to page and when users return to the site. I understand basic cookie concepts but am lost as to how to connect a cookie to the javascript function in question.
    Here's the javascript switch function, css file links, and links that do the switch:

    (function thanks to http://www.codelifter.com/main/javas...estyles.html):

    function changeSheets(whichSheet){
    whichSheet=whichSheet-1;
    if(document.styleSheets){
    var c = document.styleSheets.length;
    for(var i=0;i<c;i++){
    if(i!=whichSheet){
    document.styleSheets[i].disabled=true;
    }else{
    document.styleSheets[i].disabled=false;}}}}

    <style type="text/css">@import "/_n/s/blue_1.css";</style>
    <style type="text/css">@import "/_n/s/aqua_2.css";</style>
    <style type="text/css">@import "/_n/s/deep_3.css";</style>
    <style type="text/css">@import "/_n/s/black_4.css";</style>
    <style type="text/css">@import "/_n/s/purple_5.css";</style>
    <style type="text/css">@import "/_n/s/blue_1.css";</style>

    <a href="javascript:changeSheets(1)">switch 1</a>
    <a href="javascript:changeSheets(2)">switch 2</a>
    <a href="javascript:changeSheets(3)">switch 3</a>
    <a href="javascript:changeSheets(4)">switch 4</a>
    <a href="javascript:changeSheets(5)">switch 5</a>

    I'd really appreciate any help and would be happy to make a donation to whoever helps me get this working properly...

  2. #2
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nevermind... somehow I missed http://www.dynamicdrive.com/dynamici...etswitcher.htm - will try that instead. I must be tired...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •