Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Javascript Theme Switcher Help
So i'm trying to set up a basic realtime theme switcher for a site. i have,
<link rel='stylesheet' type='text/css' href='css/default.css' id="theme" name="theme">
and the js/form:
function switchtheme()
{
document.theme.href="css/default.css";
}
function switchthemealt()
{
document.theme.href="css/alt.css";
}
</script>
<form name="themeswitcher">
Change the Theme:<br />
<select name='theme'>
<option class='main' value='alt' onclick="switchthemealt()">Alternate</option>
<option class='main' value='default' onclick="switchtheme()">Default</option>
</select>
Where i have a dir called css and two files: default.css and alt.css
However nothing happens when i change the select. Can anyone tell me if im doing something wrong or if this is even possible to do this way. Any help is greatly appreciated. thx
-atrcomb
I've coded exactly what you want….
- Searches for code sample *
function changeStyle ( newStyle ) {
document.getElementsByTagName("link")[0].setAttribute("href","/template/templates/"+newStyle+".css");
document.cookie="style="+newStyle;
}
Source <link rel="stylesheet" type="text/css" href="web.css" />
Did it work?