PDA

View Full Version : Changing html via links.


Taisa
10-08-2002, 09:40 PM
What I'm looking to do is to have the .css sheet change in the header (from say, css1 to css2) when someone clicks the appropriate link (say, from purple to orange) and to stay that way via a cookie or what not.

Any help is appriciated, whether it be a url pointing somewhere or whatever you've got. Thanks. :D

ecnarongi
10-08-2002, 10:31 PM
I guess you want to do more than just onClick="this.style.color='orange'" you are trying to keep the state so that when a person comes in the next time the link will still be orange???

boywonder
10-09-2002, 02:31 AM
You can change an external style sheet on the fly like so:

in the head...
<link id="extCSS" type="text/css" rel="stylesheet" href="mysheet1.css">

in the body...
<a href="" onClick="document.getElementById('extCSS').href='mysheet2.css'; return false;">click</a>

Look at some cookie tutorials for saving the client's preference for future visits. Gotta run right now but I can elaborate on that if you still have trouble.