Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Let the user change the CSS document

How do I do it?



6:15 pm on Mar 1, 2004 (gmt 0)

10+ Year Member


I've been hunting around on the web for ages looking for this - please help! I want to do two things:

1. Have a link to a text-only version (i.e. switch CSS) on the main graphical version, and a link to the graphical version when users are in the text-only version (switch CSS back).

2. Have the web pages automatically load up the text-only version CSS for IE 4 and Netscape 4 and lower, and not provide the option to change. (The CSS I'm using doesn't doesn't make the page look very good in these browsers)

Any JavaScript geniuses out there who know the answer?


9:57 am on Mar 2, 2004 (gmt 0)

10+ Year Member

I'll attempt the first one.

Off the top of my head not tested, something like

function toggleCS()

<A href="javascript:toggleCS()">CSS Toggle</a>

Switches off/on linked style sheets



4:36 am on Mar 5, 2004 (gmt 0)

10+ Year Member

I your link tag looks like this:

<link rel="stylesheet" id="styletag" type="text/css" media="screen" href="graphical.css">

You can just change the value of the href attribute and the browser will load the other stylesheet and the appearance of the page will change accordingly.

javascript function to do this would be:

function modifyStyle(newfile) {
var x = document.getElementById('styletag');

You would call it from, presumably, a button like this:

<input type="button" value="Text Only" onclick="modifyStyle('textonly.css');">

to revert back to graphical stylesheet, make another button with:

Hope this helps.


Featured Threads

Hot Threads This Week

Hot Threads This Month