I have a script (JavaScript) which enables a user to switch between two style sheets on a website. Only problem is, when they visit a different page in the site, the style sheet goes back to the default.
I'm doing the site in ASP.NET and it doesn't have a user logins or anything. I just want the style sheet to at least stay as the user has selected until the browser is closed, is this possible?
The script is below, it was taken from a tutorial on the web (i'm a beginner to this):
And then two links at the bottom for each style sheet:
And obviously the two style sheet bits in the head tags:
I'm doing the site in ASP.NET and it doesn't have a user logins or anything. I just want the style sheet to at least stay as the user has selected until the browser is closed, is this possible?
The script is below, it was taken from a tutorial on the web (i'm a beginner to this):
Code:
<script language="JavaScript">
<!--
var doAlerts=true;
function changeSheets(whichSheet){
whichSheet=whichSheet-1;
if(document.styleSheets){
var c = document.styleSheets.length;
if (doAlerts) alert('Change to Style '+(whichSheet+1));
for(var i=0;i<c;i++){
if(i!=whichSheet){
document.styleSheets[i].disabled=true;
}else{
document.styleSheets[i].disabled=false;
}
}
}
}
//-->
</script>
And then two links at the bottom for each style sheet:
Code:
<a href="JavaScript:changeSheets(1)"><img src="images/stylesheetcolour2.gif" alt="Blue" border="0"></a>
<a href="JavaScript:changeSheets(2)"><img src="images/stylesheetcolour1.gif" alt="Red" border="0"></a>
And obviously the two style sheet bits in the head tags:
Code:
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<link href="StyleSheet2.css" rel="stylesheet" type="text/css" />
Last edited: