var hexPairs = new Array("00","33","66","99","CC","FF"); var L=hexPairs.length,str = '',temp; var bstr= (document.layers)?'bgcolor="#' : 'style="background-color:#'
document.writeln('<div><table border="2" ><tbody>'); for (var i = 0; i <L; i++) { document.writeln('<tr>'); for (var j = 0; j < L; j++) { for (var k = 0; k < L; k++) { var temp= ''+hexPairs[i] +''+ hexPairs[j]+'' + hexPairs[k]; str += '<td '+ bstr + temp + '" title="#'+ temp + '">'; str +='__</td>'; } document.writeln(str); str = ''; } document.writeln('</tr>'); } document.writeln('</tbody></table>'); document.close();
//--> </script> <noscript><a href="index.html">OOps...Better get out of here, it's nothing.</a></noscript> </body> </html>[/CODE]
@felgallJan 05.2007 — #If you look at both 256 colour mode and 65k colour mode then there are only 7 safe colours and all of them are shades of green. If you look as 65k and 16M colour mode then there are 65k safe colours. The so called safe colours involving the hex pairs that the script above generates is only safe if you disregard 65k mode. As most people have their browser set to either 65k or 16M mode these days the so called safe colours are no longer of any relevance and if you want to include both 256 colour and 65k modes in your consideration then only the 7 shades of green will display the same shade in both.
@om_26authorJan 08.2007 — #Hi mrhoo thx alots for ur codes..well its works but am trying to understand the codes..very confusing !! ..posible for any explanation especially the variable declaration and the for-loop part..!!!!!!!!!!!!!!!!!
what is being looped through in that table are the hexadecimal equivilents of these decimal percentages in sets of 3- the red, green, and blue components of the complete color string.
For instance, in hexadecimal, 33 has the same ratio to ff that 20 has to 100 in decimal.
Likewise 66 and 40, 99 and 60, CC and 80, and ff and 100.
I don't pay any attention to web safe these days, though we all did ten years ago. But I still like hexadecimal math.