althalus
08-21-2004, 08:43 PM
not sure where to begin with this one..
i recieved a theme-switcher script from willy duitt a while ago that works well in the example file, but not very well on the server. i would've asked him for help, but i just realised that he was catapulted some time ago, so.. :/
the script is as follows:
<script type="text/javascript">
<!--//
function setCookie(new_style) {
var which = document.getElementsByTagName('a');
var what = which[new_style-1].name;
var duitt = new Date();
duitt.setTime(duitt.getTime() + 365*24*60*60*1000);
var expString = "; expires=" + duitt.toGMTString();
document.cookie = 'My_Style='+what+expString;
}
function setStyle(which_style) {
if(/My_Style=style_(\d*)/.test(document.cookie)) {
which_style = RegExp.$1*1;
}
else {
which_style = which_style;
}
if(document.styleSheets) {
which_style = which_style-1;
for(i=0;i<document.styleSheets.length;i++) {
if(i!=which_style) {
document.styleSheets[i].disabled=true;
}
else {
document.styleSheets[i].disabled=false;
}
}
}
}
setStyle(1);
//-->
</script>
and is then run with
<a name="style_1" href="javascript:setStyle(1)" onclick="setCookie(1)">style one</a>
<a name="style_2" href="javascript:setStyle(2)" onclick="setCookie(2)">style two</a>
and so on...
it can be seen in "action" at http://mng.zinix.net .
any help is appreciated. thank you!
i recieved a theme-switcher script from willy duitt a while ago that works well in the example file, but not very well on the server. i would've asked him for help, but i just realised that he was catapulted some time ago, so.. :/
the script is as follows:
<script type="text/javascript">
<!--//
function setCookie(new_style) {
var which = document.getElementsByTagName('a');
var what = which[new_style-1].name;
var duitt = new Date();
duitt.setTime(duitt.getTime() + 365*24*60*60*1000);
var expString = "; expires=" + duitt.toGMTString();
document.cookie = 'My_Style='+what+expString;
}
function setStyle(which_style) {
if(/My_Style=style_(\d*)/.test(document.cookie)) {
which_style = RegExp.$1*1;
}
else {
which_style = which_style;
}
if(document.styleSheets) {
which_style = which_style-1;
for(i=0;i<document.styleSheets.length;i++) {
if(i!=which_style) {
document.styleSheets[i].disabled=true;
}
else {
document.styleSheets[i].disabled=false;
}
}
}
}
setStyle(1);
//-->
</script>
and is then run with
<a name="style_1" href="javascript:setStyle(1)" onclick="setCookie(1)">style one</a>
<a name="style_2" href="javascript:setStyle(2)" onclick="setCookie(2)">style two</a>
and so on...
it can be seen in "action" at http://mng.zinix.net .
any help is appreciated. thank you!