Follow us on Twitter!
Society leans ever heavily on computers, if you have the power to take out computers you can take out society. - cubeman372
Saturday, April 19, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 73
Guests Online: 68
Members Online: 5

Registered Members: 82839
Newest Member: fezphantom
Latest Articles
View Thread

HellBound Hackers | Computer General | Webmasters Lounge

Author

Javascript Theme Switcher Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 02-04-07 16:27
So i'm trying to set up a basic realtime theme switcher for a site.
i have,
Code

<link rel='stylesheet' type='text/css' href='css/default.css' id="theme" name="theme">




and the js/form:
Code

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




Edited by on 02-04-07 16:39
Author

RE: Javascript Theme Switcher Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 02-04-07 16:56
I have something similar... But I use "getElementById('theme'Wink" to select the thingy


Author

RE: Javascript Theme Switcher Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 02-04-07 17:25
I've coded exactly what you want....

* Searches for code sample *

Code

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?




Edited by on 07-04-07 21:46