Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-21-2005, 05:29 AM   PM User | #1
rdjdnd
New to the CF scene

 
Join Date: Jan 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
rdjdnd is an unknown quantity at this point
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];
}
}
}
rdjdnd is offline   Reply With Quote
Old 04-21-2005, 05:41 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Maybe cookie is disabled in the settings?
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 04-21-2005, 05:48 AM   PM User | #3
rdjdnd
New to the CF scene

 
Join Date: Jan 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
rdjdnd is an unknown quantity at this point
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?
rdjdnd is offline   Reply With Quote
Old 04-21-2005, 06:57 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 04-21-2005, 02:21 PM   PM User | #5
rdjdnd
New to the CF scene

 
Join Date: Jan 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
rdjdnd is an unknown quantity at this point
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 03:40 PM..
rdjdnd is offline   Reply With Quote
Old 04-22-2005, 02:15 AM   PM User | #6
rdjdnd
New to the CF scene

 
Join Date: Jan 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
rdjdnd is an unknown quantity at this point
any help would be appreciated.

Thanks
rdjdnd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:12 AM.


Advertisement
Log in to turn off these ads.