Color Table

JavaScript giúp bạn thao tác các nền tài liệu . Hoặc chọn màu bạn muốn bằng tên của nó , hoặc tạo ra một màu sắc độc đáo bằng cách sử dụng " + " và " -" nút Red , Green , và Blue. Một tác dụng thực sự gọn gàng .
<!-- Begin
function changeBackground(hexNumber) {
document.bgColor=hexNumber
}
prefix="#"
rnum1=0
bnum1=0
gnum1=0
rnum2=0
bnum2=0
gnum2=0
hexNumber2="#000000";
rcount=0;
bcount=0;
gcount=0;
function num2hex(num) {
if (num==15) return "f";
else if (num==14) return "e";
else if (num==13) return "d";
else if (num==12) return "c";
else if (num==11) return "b";
else if (num==10) return "a";
else if (num==9) return "9";
else if (num==8) return "8";
else if (num==7) return "7";
else if (num==6) return "6";
else if (num==5) return "5";
else if (num==4) return "4";
else if (num==3) return "3";
else if (num==2) return "2";
else if (num==1) return "1";
else return "0";
}
function changeBackground2(number) {
if(number == 1) {
rnum1=rcount%16;
if (rcount <15) {
rcount=rcount+1;
  }
}
if(number == 2) {
gnum1=gcount%16;
if (gcount <15) {
gcount=gcount+1;
  }
}
if(number == 3) {
bnum1=bcount%16;
if (bcount <15) {
bcount=bcount+1;
  }
}
if(number == 4) {
rnum1=rcount%16;
if (rcount > 0) {
rcount=rcount-1;
  }
}
if(number == 5) {
gnum1=gcount%16;
if (gcount > 0) {
gcount=gcount-1;
  }
}
if(number == 6) {
bnum1=bcount%16;
if (bcount > 0) {
bcount=bcount-1;
  }
 }
hexNumber2 = prefix+num2hex(rnum1)+num2hex(rnum2)+num2hex(gnum1)+num2hex(gnum2)+num2hex(bnum1)+num2hex(bnum2);
  document.bgColor=hexNumber2
}
// End -->
</script>
<center>
<form method="POST" name="background">
<table border="3" cellpadding="3" style="width: 350px;"><tbody>
<tr> <td align="center"><input onclick="changeBackground('#FF0000')" type="button" value="Red" /></td> <td align="center"><input onclick="changeBackground('#00FF00')" type="button" value="Green" /></td> <td align="center"><input onclick="changeBackground('#0000FF')" type="button" value="Blue" /></td> <td align="center"><input onclick="changeBackground('#FFFFFF')" type="button" value="White" /></td> <td align="center"><input onclick="changeBackground('#000000')" type="button" value="Black" /></td> <td align="center"><input onclick="changeBackground('#C0C0C0')" type="button" value="Grey" /></td> </tr>
</tbody></table>
<table border="3" cellpadding="3" style="width: 350px;"><tbody>
<tr><td><center>
Variable Background Color Changer</center>
</td> </tr>
</tbody></table>
<table border="3" cellpadding="3" style="width: 350px;"><tbody>
<tr> <td align="center"><input onclick="changeBackground2(1)" type="button" value="+ Red" />
<input onclick="changeBackground2(4)" type="button" value="- Red" /></td> <td align="center"><input onclick="changeBackground2(2)" type="button" value="+ Green" />
<input onclick="changeBackground2(5)" type="button" value="- Green" /></td> <td align="center"><input onclick="changeBackground2(3)" type="button" value="+ Blue" />
<input onclick="changeBackground2(6)" type="button" value="- Blue" /></td> </tr>
</tbody></table>
<table border="3" cellpadding="3" style="width: 350px;"><tbody>
<tr> <td><center>
Keep pressing buttons to change color

(The color will start as black)</center>


Variable Background Color Changer



Keep pressing buttons to change color

(The color will start as black)



<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function color(frm, clr, val) {
v = eval("0x" + frm[clr].value) + val;
if (v < 0 || v > 255) v -= val;
v = v.toString(16).toUpperCase();
while (v.length < 2) v = "0" + v;
frm[clr].value = v; nc = "";
for(i = 1; i < 8; i += 3) nc += frm.elements[i].value;
document.bgColor = nc;
}
function setval(item) {
v = prompt("New value for " + item.name + " (00 - FF)", item.value);
if (v) {
v = eval("0x" + v);
if ((v & 255) == v) {
item.value=v.toString(16).toUpperCase();
while (item.value.length < 2) item.value = "0" + item.value;
color(document.f, item.name, 0);
      }
   }
}
//  End -->
</script>
<center>
<form name=f>
<table border=1>
<tr>
<td colspan=3 align=center bgcolor="#ff0000">RED</td>
<td colspan=3 align=center bgcolor="#00ff00">GREEN</td>
<td colspan=3 align=center bgcolor="#000ff">BLUE</td>
</tr>
<tr>
<td><input type=button name=rm value="<" onclick = "color(this.form, 'Red' , -1);"></td>
<td><input type=button name=Red value="AF" onclick = "setval(this);"></td>
<td><input type=button name=rp value=">" onclick = "color(this.form, 'Red', 1);"></td>
<td><input type=button name=gm value="<" onclick = "color(this.form, 'Green', -1);"></td>
<td><input type=button name=Green value="BF" onclick = "setval(this);"></td>
<td><input type=button name=gp value=">" onclick = "color(this.form, 'Green', 1);"></td>
<td><input type=button name=bm value="<" onclick = "color(this.form, 'Blue', -1);"></td>
<td><input type=button name=Blue value="CF" onclick = "setval(this);"></td>
<td><input type=button name=bp value=">" onclick = "color(this.form, 'Blue', 1);"></td>
</tr>
</table>
</form>
</center>


RED GREEN BLUE



Color Wheel
<SCRIPT LANGUAGE="JavaScript">

<!-- Original: Eric Stremming <estremming@hotmail.com>  -->
<!-- Web Site: http://www.geocities.com/SunsetStrip/Club/5970  -->



<!-- Begin
var pos = 10;
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
   }
}
var col=new initArray("4b","5b","8b","8b");
function stop() {
document.bgColor = '#FFFFFF';
clearTimeout(loopID);
}
function start() {
col[1]="red"
col[2]="yellowgreen"
col[3]="yellow"
col[4]="whitesmoke"
col[5]="white"
col[6]="wheat"
col[7]="violet"
col[8]="turquoise"
col[9]="tomato"
col[10]="thistle"
pos++;
if (pos<0||pos>10) {
pos = 0;
}
document.bgColor = col[pos];
loopID = setTimeout("start()",50);
}
// End -->
</SCRIPT>
<!-- STEP TWO: Add the onLoad event handler to the BODY tag  -->

<BODY onLoad="start()">

<!-- STEP THREE: Copy this last code into the BODY of your HTML document  -->

<CENTER>
<FORM>
<input type="button" value="On" onClick="start()">
<input type="button" value="Off" onClick="stop()">
</FORM>
</CENTER>



<SCRIPT LANGUAGE="JavaScript">


<!-- Begin
function blinkit(){
intrvl=0;
for(nTimes=0;nTimes<3;nTimes++){
intrvl += 200;
setTimeout("document.bgColor='#0000FF';",intrvl);
intrvl += 200;
setTimeout("document.bgColor='#FFFFFF';",intrvl);
   }
}
// End -->
</SCRIPT>
<FORM>
<INPUT TYPE="BUTTON" VALUE="Blink" onClick="blinkit()">
</FORM>































0 Comment "

Color Table

"

Đăng nhận xét

Bạn có thể test thử trên Test Html Editor Chọn> Mã màu