ruler1
MIS
- Feb 19, 2007
- 89
hi, i found another post on here but lost the url so i cant refer to it but i used their code which works good eccept for one small problem.
the code below allows me to change styles on my pages and saves the selection for the next time i connect to my site however when you first visit there is no default set so you dont get any styles until you actually select one. i was wondering if there was a way to have a default style set for when a user first connects to my pages? here is the code below...
<html>
<head>
<link id="external_style" rel="stylesheet" type="text/css"/>
</head>
<body onLoad="loadStyle()">
<script language="javascript">
var CSS_COOKIE_VAR = "LastCSS";
function changeStyle( oSel )
{ if (sCSS = oSel.value)
{ setStyle( sCSS );
var expires = new Date( 2010, 1, 1 ); // long enough
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.split("=");
if (aName[0] == CSS_COOKIE_VAR )
{ setStyle( aName[1] );
document.getElementById("control").value = aName[1];
}
}
}
</script>
<form>
<select id="control" name="style" onChange="changeStyle(this)">
<option value="/ <option value="/ <option value="/</select>
</form>
</body>
</html>
the code below allows me to change styles on my pages and saves the selection for the next time i connect to my site however when you first visit there is no default set so you dont get any styles until you actually select one. i was wondering if there was a way to have a default style set for when a user first connects to my pages? here is the code below...
<html>
<head>
<link id="external_style" rel="stylesheet" type="text/css"/>
</head>
<body onLoad="loadStyle()">
<script language="javascript">
var CSS_COOKIE_VAR = "LastCSS";
function changeStyle( oSel )
{ if (sCSS = oSel.value)
{ setStyle( sCSS );
var expires = new Date( 2010, 1, 1 ); // long enough
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.split("=");
if (aName[0] == CSS_COOKIE_VAR )
{ setStyle( aName[1] );
document.getElementById("control").value = aName[1];
}
}
}
</script>
<form>
<select id="control" name="style" onChange="changeStyle(this)">
<option value="/ <option value="/ <option value="/</select>
</form>
</body>
</html>