123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home

Source Codes

Engineering Colleges

BE Students

Training  Reports (updated)

Seminar Reports (updated

Placement Papers (updated)

Forums

   Computer Science / IT

   Electronics

   Electrical

   Mechanical

   Chemical

   Civil

   CAT / MBA

   GMAT / Foreign MBA

Latest Jobs

Engineering Jobs / Technical Jobs

Management Jobs

Sitemap

About-Us

Terms of use

Displaying  Source Code(s)  
 

 
Safe Colors

--------------------------------------------------------------------------------

Description : 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.

<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>
 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG