96turnerri
01-08-2004, 07:11 AM
hi i have got a js based stylesheet changer
heres the script
<head>
<script language="JavaScript" type="text/javascript">
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
</script>
<LINK href="style-blue.css" type="text/css" rel="stylesheet" title="Blue">
<LINK href="style-green.css" type="text/css" rel="alternate stylesheet" title="Green">
<LINK href="style-red.css" type="text/css" rel="alternate stylesheet" title="Red">
<LINK href="style-black.css" type="text/css" rel="alternate stylesheet" title="Black">
</head>
and heres one of my calling function
<a href="#"
onclick="setActiveStyleSheet('Blue'); document.images[18].src='table-top.jpg';
return false;">Blue</a>
what i would like is a cookie to be set either onunload or when the user clicks one of the calling functions
then when the user returns it remembers last stylesheet they were using
this would be a great help
thanks 96
one more thing i found this 'tutorial' but that didnt work for me either :( so someone may wis to start with that
http://www.alistapart.com/articles/alternate/
heres the script
<head>
<script language="JavaScript" type="text/javascript">
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
</script>
<LINK href="style-blue.css" type="text/css" rel="stylesheet" title="Blue">
<LINK href="style-green.css" type="text/css" rel="alternate stylesheet" title="Green">
<LINK href="style-red.css" type="text/css" rel="alternate stylesheet" title="Red">
<LINK href="style-black.css" type="text/css" rel="alternate stylesheet" title="Black">
</head>
and heres one of my calling function
<a href="#"
onclick="setActiveStyleSheet('Blue'); document.images[18].src='table-top.jpg';
return false;">Blue</a>
what i would like is a cookie to be set either onunload or when the user clicks one of the calling functions
then when the user returns it remembers last stylesheet they were using
this would be a great help
thanks 96
one more thing i found this 'tutorial' but that didnt work for me either :( so someone may wis to start with that
http://www.alistapart.com/articles/alternate/