| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2007
Location: Midlands, UK
Posts: 46
|
User chooses CSS theme for site?
Whats the best way to use multiple css scripts on a site? I want the user to be able to select what color they want the site to use and the site continues to use this theme while they navigate through the pages on the site. Thanks |
|
|
|
|
|
#3 (permalink) |
|
Shun the non-believer
|
As INXS said, you can achieve this with PHP. You'll want to be looking at cookies though (so the site can read the users' colour/display preference). I've seen some nice live CSS switchers using JavaScript so you might want to look in to that too... - Mike |
|
|
|
#4 (permalink) |
|
unusual suspect ™
Join Date: Jul 2004
Location: DE, USA
Posts: 4,676
|
I used PHP for this on my portfolio (click on any of the 1-12 at the bottom) but I since prefer JavaScript solutions. |
|
|
|
#9 (permalink) |
|
now with added beard
Join Date: Mar 2004
Location: Liverpool
Posts: 8,023
|
ha ha ... well, apart from those people and their testing processes ... i'd assume they are using something like the web developers toolbar, and switch various things on and off for the afore mentioned testing purposes ... joe public doesn't even know what javascript is, so why would he turn it off ?? i think he wouldn't ... ![]() |
|
|
|
#11 (permalink) |
|
Whitey
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,286
|
That's how I would do it. As for who disables javascript - I do. Pages load faster, because they don't need to load unnecessary crap. It also helps prevent some spyware from getting in, and allows you to decide if you are going to be tracked or not (google analytics etc). And any javascript-loaded advertising doesn't come through. One of the more popular firefox addons out there is noscript (I use it), which disables javascript by default, and can be used to allow whichever domains you want. |
|
|
|
#12 (permalink) |
|
or just Kris
Join Date: Jun 2005
Location: Brussels - Belgium
Posts: 176
|
I would consider doing this in javascript only. That said I mean adding the necessary nodes (the hyperlinks that trigger the switch) and inner html through js and not adding them to the markup. If javascript is disabled no cookie can be stored either to remember the choice. So unless you would be storing that data in a database there really is no point in being able to switch on the server side imho... |
|
|
|
#13 (permalink) | |
|
What happened?
Join Date: Jul 2008
Posts: 1,826
|
Quote:
|
|
|
|
|
#17 (permalink) |
|
Whitey
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,286
|
This can still build up, and slow things down. For example, if you make 20 http requests on a page, the cookie is sent (and received) 20 times from the server. One way you can get around this is to have the non-www version of your domain always forward to the www version of your domain. Then you create a subdomain, for example, static.domain.com, and you put any static images/javascript/css in the static domain. Since cookies are only sent for the domains for which they are a part of, and static.domain.com is not the same as www.domain.com, any requests to static.domain.com will not send the cookie. So in your html, you use an absolute URL with static.domain.com to get the images. |
|
|
|
#20 (permalink) |
|
Registered User
Join Date: Jan 2009
Posts: 1
|
DynamicDrive CSS Switcher
I recently found a JS CSS switcher on Dynamic Drive. Located under "User & System Preference" -> "Style Sheet Switcher" Haven't had a chance to try it out, but thought I'd pass it on in case anyone else was looking for something similar. |
|
![]() |
|