
Originally Posted by
Studly Cannon
AlistairH, that's exactly what I'm looking for, but I don't use PHP on my pages...
Any server-side language is suitable, if you have none available at all, then you can use the client-side code that I posted. I just suggested that it's best to use both in tandem as it provides a guaranteed solution that will work for everyone. If you do use the suggestion in the thread Alistair cited, use the first version.
That said, if you're changing colours interactively, rather than changing the style sheet itself, then it isn't a good solution.
As for changing body text colours:
Code:
function setColours(foreground, background) {
var body = document.body,
style;
if(body && (style = body.style)) {
style.color = foreground;
style.backgroundColor = background;
}
}
The expected arguments are strings that specify a colour in some CSS-compliant way.
<a href="javascript
:void(0)"
The javascript: pseudo-scheme should rarely ever be used as it tends to cause problems, such as stopping animation, and being nonsense for script-disabled user agents. If you really cannot provide a link to somewhere useful, then use a pattern like:
HTML Code:
<a href="#" onclick="/* ... */; return false;">...</a>
With regard to the onclick attribute, you can only have one per element (that's true of any attribute) so you must combine the two by ending the first statement with a semicolon. The HTML snippet above shows this to a degree.
Mike
Bookmarks