CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 11th, 2003, 10:23 AM
munna munna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 30 munna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
how to do css style changes?

Hi,
I would like to give visitors to my page the option of choosing from a number of different stylesheets. I remember seeing a javascript to do this ages ago, but can't find it now. Please can anyone tell me how to do this, or send me a link for a suitable code snippet?
Thanks,
Munna

Reply With Quote
  #2  
Old August 11th, 2003, 10:26 AM
ctstone's Avatar
ctstone ctstone is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 147 ctstone User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
you could write a function to modify this DOM property:
Code:
document.styleSheets[0].href

Just set it to the filenames of your other style sheets.

Reply With Quote
  #3  
Old August 11th, 2003, 10:31 AM
munna munna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 30 munna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
ctstone,
I'm a newbie to javascript -- please can you explain a bit more in detail?
munna

Reply With Quote
  #4  
Old August 11th, 2003, 10:44 AM
ctstone's Avatar
ctstone ctstone is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 147 ctstone User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Sure, I'll assume you have a drop down menu with the id my_css which looks something like this:
Code:
<select id="my_css" onchange="set_css(this)">
<option value="style1.css">style 1</option>
<option value="style2.css">style 2</option>
</select>

Then you want a function called set_css that looks like this:
Code:
function set_css(the_select) {
	var the_css = the_select.options[the_select.selectedIndex].value;
	document.styleSheets[0].href = the_css;
}


Hope that works for you.
__________________
ctnstone.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > how to do css style changes?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway