Try the below modified .js file, which lets you completely switch between one main stylesheet and a choice of various alternate stylesheets. When the user chooses an alternate stylesheet, the main one is disabled. For the new .js file to work, you have to give your main stylesheet a title of "main", and also pass in that value when dynamically switching stylesheets by calling chooseStyle(). The below HTML illustrates the necessary changes:
Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="default.css" title="main" />
<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" />
<script src="styleswitch.js" type="text/javascript">
/***********************************************
* Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
</head>
<body>
<form id="switchform">
<input type="radio" name="choice" value="main" onClick="chooseStyle(this.value, 60)">Default style<br />
<input type="radio" name="choice" value="blue-theme" onClick="chooseStyle(this.value, 60)">Blue Theme<br />
<input type="radio" name="choice" value="brown-theme" onClick="chooseStyle(this.value, 60)">Brown Theme
</form>
// Rest of body here
</body>
</html>
In the above case, when the user chooses the "blue" theme for example, default.css is disabled while user.css is applied.
Bookmarks