View Full Version : link problem

09-29-2007, 09:31 AM
Hi everyone, Im having a bit of a problem getting a onClick to change the different link values.

Im trying to switch the black ground and link colors, but I cant figure out the right 'definition' for the link styles..

I can get this to work for the background color,
onClick="document.body.style.backgroundColor = 'white';"

But I dont know what to type after document.body.style. for the different link values, a:link v:link etc. Ive been searching google for a couple hours and just cant seem to find anything on it.


09-29-2007, 10:54 AM
You won't like my choice of colours but it works otherwise:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<title>Untitled Page</title>
<style type="text/css">
.xxx {background-color: #ccffcc}
.xxx a:link {color: #f00}
.xxx a:visited {color: #800080}
<a href="#">Going nowhere...</a>
<input type="button" onclick="javascript:document.body.className='xxx';" value="All change" />

09-29-2007, 09:25 PM
Hey thanks a lot, worked like a charm!