Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cookies and Internet Explorer

    I'm trying to have a user who visits my site be able to select the style sheet they'd like to see and it save as a cookie. I was given some javascript that would help me out and it has to a certain extent. With firefox the user can select the style and it saves, all is well. With Internet Explorer 6 and Service Pack 2 installed the style doesn't get saved and it reverts back to the default. I've tested this on several computers all with Service Pack 2 and IE6. I have no idea why it does. I don't get any errors. If anyone could help me out that would be great, I am very new to Javascript and know nothing about it. My site is www.dempsey.cjb.net and here is the javascript that I currently use.

    -----code------

    var CSS_COOKIE_VAR = "LastCSS";

    function changeStyle( oSel )
    { if (sCSS = oSel.value)
    { setStyle( sCSS );
    var expires = new Date( 2010, 1, 1 );
    document.cookie = CSS_COOKIE_VAR + "=" + escape( sCSS ) +"; expires=" + expires.toGMTString() + ";" ;
    }
    }

    function setStyle( sCSS )
    { document.getElementById("external_style").href = sCSS;
    }

    function loadStyle()
    { aCookie = document.cookie.split(";");
    for (i=0; i< aCookie.length; i++)
    { aName = aCookie[i].split("=");
    if (aName[0] == CSS_COOKIE_VAR )
    { setStyle( aName[1] );
    document.getElementById("control").value = aName[1];
    }
    }
    }

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Maybe cookie is disabled in the settings?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your quick reply. Well it was tried at several different computers, the people who did it wouldn't know how to turn cookies off. I know on my computer they aren't turned off. Is that what you mean?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Try alerting document.cookie after it is set and as the style is loaded. I have no IE SP2 so I can't see the default cookie settings but I know that with SP2, IE becomes stricter. Look at the Privacy tab of the Internet Options.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sorry glenngv but i'm really new at javascript could you perhaps fully write out exactly what I should try, I have no clue how to go about what you suggested. Thanks for your help. I really do appreciate it.
    Last edited by rdjdnd; 04-21-2005 at 04:40 PM.

  • #6
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any help would be appreciated.

    Thanks


  •  

    Posting Permissions

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