|
Safe Colors by Charles Carroll
The script below demonstrates two things:
how easy it is to mix Jscript and VBscript in
the same file
samples of web safe colors. These colors will
appear the same on almost everybody's browser. Other colors may appear dramatically
different from browser to browser.
filename=/learn/test/safecolors.asp
<html><head>
<title>websafe.asp</title></head>
<body bgcolor="#FFFFF">
<%
whitetext="<font face='arial black' size='4' color='white'>"
blacktext="<font face='arial black' size='4'>"
colortext="<font face='arial black' size='4' color='"
spacer=" "
response.write blacktext & "<table border=0>"
for counter=1 to 6
safecolor1=websafe(counter)
for counter2=1 to 6
safecolor2=websafe(counter2)
for counter3= 1 to 6
safecolor3=websafe(counter3)
hexcolor=convertToHex(safecolor1,safecolor2,safecolor3)
response.write "<tr><td>" & hexcolor & "</td>"
response.write "<td bgcolor='" & hexcolor & "'>" & whitetext
response.write " White Text </td>"
response.write "<td bgcolor='" & white & "'>" & colortext & hexcolor & "'>"
response.write " Colored Text </font></td>"
response.write "<td bgcolor='" & hexcolor & "'>" & blacktext
response.write " Black Text </td>"
response.write "</tr>"
for counter4=1 to 4
response.write "<td bgcolor='#FFFFF'>" & spacer & "</td>"
next
response.write "<tr>"
next
next
next
response.write "</table>"
%>
</body></html>
<%
function websafe(mynumber)
SELECT CASE mynumber
CASE 1
websafe=0
CASE 2
websafe=51
CASE 3
websafe=102
CASE 4
websafe=153
CASE 5
websafe=204
CASE 6
websafe=255
END SELECT
end function
%>
<script language=jscript runat=server>
function convertToHex(R, G, B) {
var n = B;
n += G << 8;
n += R << 16;
return convertBase(n);
}
// turns decimal integer into hexadecimal string
function convertBase(num) {
var i = 0; var j = 20;
var str = "#";
while(j >= 0) {
i = (num >> j)%16;
if(i >= 10) {
if(i == 10) str += "A";
else if(i == 11) str += "B";
else if(i == 12) str += "C";
else if(i == 13) str += "D";
else if(i == 14) str += "E";
else str += "F";
} else
str += i;
j -= 4;
}
return str;
}
</script>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|