/    Sign up×
Community /Pin to ProfileBookmark

swapping styles

Hi

I’ve read lots of references to ‘swapping styles’ but unfortunately none of them explain how to do it; it’s obviously so simple that everyone knows how (except for me)!

What I want to do is to offer the user a choice of colour schemes and I guess that is best done by just applying a style sheet according to the selection made by the user.

I currently use a LINK tag to define the css file to use but that has to go in the HEAD section so how can I control that with javascript?

Many thanks
M

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@Ben_RogersJul 09.2004 — The alternate stylesheets article on A List Apart explains very clearly how to create a style switcher. <http://www.alistapart.com/articles/alternate/>
Copy linkTweet thisAlerts:
@Daniel_TJul 09.2004 — [i]Originally posted by omega [/i]

[B]The alternate stylesheets article on A List Apart explains very clearly how to create a style switcher. <http://www.alistapart.com/articles/alternate/> [/B][/QUOTE]
Better yet, do it server-side! (if he/she has PHP available to him)

http://alistapart.com/articles/phpswitch/
Copy linkTweet thisAlerts:
@Ben_RogersJul 09.2004 — That depends on your audience. The JS method I posted is faster, but only works if JS is available to the viewer- Dan's link should be used if 100% of your users _must_ have this style switcher.
Copy linkTweet thisAlerts:
@CharlesJul 09.2004 — [font=georgia]I tend to think of style switching as one good use for JavaScript. No real harm is done if it doesn't work and proper browsers have their own mechanism to allow users to choose from the alternate stylesheets. [/font]
Copy linkTweet thisAlerts:
@Orsen_CartauthorJul 09.2004 — Can't wait to give it a go!!!
×

Success!

Help @Orsen_Cart spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...