Click to See Complete Forum and Search --> : Is it possible...


Greelmo
05-14-2003, 02:51 PM
Is it possible to automatically change the entire documents font color from java? I did something like this...

<SCRIPT LANGUAGE="JavaScript">
function fnccolor(colory)
{
document.font.style.color=colory
}
</script>

Where colory is equal to the value in a text box in the body and the function is activated through a button... it obviously doesn't work now, but i would be very happy if any of you knew how to do it.

Jona
05-14-2003, 03:10 PM
Your code does work, but only if you have this somewhere in your document:

<div id="font">Text</div>

Jona
05-14-2003, 03:12 PM
You can also use that function to change the color of every element on the page. Watch:

function changeFGColor(){
if(event.srcElement.style.color=="blue"){event.srcElement.style.color="red";}
else{event.srcElement.style.color="blue";}
}

And on any element in your page:

<h1 onclick="changeFGColor()">This is blue or red?</h1>

<p onclick="changeFGColor()">Is this blue or red?</p>

<input type="button onClick="changeFGColor()" value="Is this text blue or red?">

khalidali63
05-14-2003, 03:23 PM
Change this line
document.font.style.color=colory

to this one

document.body.style.color=colory ;

this should do what you want ...:-)