Determine color in Table by pixelDepth

[Total: 0    Average: 0/5]

This example illistrates how to use javascript to create table background colors.

Body Code:

<TABLE CELLSPACING="4" CELLPADDING="2" BORDER="1"> 
<TR> 
    <TD align=center><B>Web Safe Color</B></TD> 
    <TD align=center><B>Non-Web Safe Color</B></TD> 
</TR> 
<TR> 
    <TD bgcolor="#663333">
  <FONT COLOR="#FFFFFF">#663333</FONT>
  <IMG SRC="/images/shim.gif" WIDTH="100" HEIGHT="50" BORDER="0" ALT="">
</TD>
    <SCRIPT LANGUAGE="JavaScript"> 
if (screen.pixelDepth <= 8 ) { 
      document.write('<TD bgcolor="#663333"><FONT COLOR="#FFFFFF">#663333</FONT><IMG SRC="/images/shim.gif" WIDTH="100" HEIGHT="50" BORDER="0" ALT=""></TD>'); 
} 
else { 
  document.write('<TD bgcolor="#8B7A6F"><FONT COLOR="#FFFFFF">#8B7A6F</FONT><IMG SRC="/images/shim.gif" WIDTH="100" HEIGHT="50" BORDER="0" ALT=""></TD>'); 
} 
</SCRIPT> 
</TR> 
</TABLE>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *