PDA

View Full Version : get background color


raoul
12-26-2002, 11:08 AM
Hi,

I have a section where partners are able to customize header and footer files. My website supplies the contents for these partners.

regarding certain (text) color settings I was wondering if it is possible to get the value of the body background color (set in the header file by the partner) and adapt the default text color (black) when the background color is set to black?

Thanks,
raoul

Mr J
12-26-2002, 01:20 PM
Will this set you on the right track




<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script>
function check(){
if(document.bgColor=="#000000"){
document.fgColor="#ff0000"
}
}
setTimeout("check()",1000)
</script>
</HEAD>
<BODY bgcolor="black">

This is some text

</BODY>
</HTML>

raoul
12-27-2002, 10:15 AM
Thanks!

That gives me at least some control. I played a bit with colors and hexadecimal values and for the mayority of colors (except blue and green) you can say that when the first character is 5 or lower the color is pretty dark.

although it is not 100% ideal something like this might work:

if(document.bgColor.substr(1,1) <=5 ){
document.fgColor="#ff0000"
}