PDA

View Full Version : Style Sheet Switcher (v1.0) - IE does not remember style



miodrag
05-28-2006, 04:20 AM
Question about Style Sheet Switcher (v1.0)
from: http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm

I have this script working fine with Firefox.
With IE 6 it works OK on my hard disk, but on the Web it does not remember style when refreshing a page or opening a new one:

http://www.onecreation.com/synergy/index.html

Help appreciated.

ddadmin
05-28-2006, 05:31 PM
works for me in IE6 actually- select a new style, refreshing the page retains that style. Could it be that your IE6 security settings is set to not accept cookies on the web?

BTW, you may want to add the additional code needed to have the current selection automatically checked once a new style is selected as far as the correct radio button:


<script type="text/javascript">
window.onload=function(){
var formref=document.getElementById("switchform")
indicateSelected(formref.choice)
}
</script>

See the script page for more info.

miodrag
05-28-2006, 08:29 PM
No, my cookie is updating promptly.
Checked on two more computers, and style there also retains.
No idea what is wrong with my IE.

The script you posted is already in all my pages headers.
Btw. DD page says:
>consider moving the above script inside "styleswitch.js"

If moving means copy/pasting at the end of styleswitch.js, it only disables the script completely.

MooCan
06-01-2006, 05:25 PM
Hi,

I have found why IE don't remember CSS Style on page relaunch.
I Had the same problems.

So ...
in your CSS link does not use space caracter in style title but "_" or "-" and all is OK

Not Good:
<link rel="stylesheet" type="text/css" href="default.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue theme" href="user.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="brown theme" href="user2.css" />

Good one:
<link rel="stylesheet" type="text/css" href="default.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue-theme" href="user.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="brown-theme" href="user2.css" />

Or this one too:
<link rel="stylesheet" type="text/css" href="default.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue_theme" href="user.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="brown_theme" href="user2.css" />

I think that's because in the cookie the style name is mentionned without any quote and space characters create confusion.

MooCan

miodrag
06-02-2006, 01:13 AM
Oh, good catch!

I did not have that particular problem, since I used only one word as CSS name, like "blue" or "black", no spaces.

But thanks, anyway, good to know.