提示:您可以先修改部分代碼再運行
<p><html><br /><head><br /><title>調色盤</title><br /></head><br /><body><br /><script language="JavaScript"><br /><!--</p><p>// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.<br />// Permission given to use the script provided that this notice remains as is.<br />// Additional scripts can be found at [url]http://www.geocities.com/~yehuda/[/url]</p><p>// create 6-element array<br />var hex = new Array(6)</p><p>// assign non-dithered descriptors<br />hex[0] = "FF"<br />hex[1] = "CC"<br />hex[2] = "99"<br />hex[3] = "66"<br />hex[4] = "33"<br />hex[5] = "00"</p><p>// accept triplet string and display as background color<br />function display(triplet) {<br /> // set color as background color<br /> document.bgColor = '#' + triplet</p><p> // display the color hexadecimal triplet<br /> alert('現在的背景色是 #'+triplet)<br />}</p><p>// draw a single table cell based on all descriptors<br />function drawCell(red, green, blue) {<br /> // open cell with specified hexadecimal triplet background color<br /> document.write('<TD BGCOLOR="#' + red + green + blue + '">')</p><p> // open a hypertext link with javascript: scheme to call display function<br /> document.write('<A HREF="javascript:display(\'' + (red + green + blue) + '\')">')</p><p> // print transparent image (use any height and width)<br /> document.write('<IMG SRC="place.gif" BORDER=0 HEIGHT=12 WIDTH=12>')</p><p> // close link tag<br /> document.write('</A>')</p><p> // close table cell<br /> document.write('</TD>')<br />}</p><p>// draw table row based on red and blue descriptors<br />function drawRow(red, blue) {<br /> // open table row<br /> document.write('<TR>')</p><p> // loop through all non-dithered color descripters as green hex<br /> for (var i = 0; i < 6; ++i) {<br /> drawCell(red, hex[i], blue)<br /> }</p><p> // close current table row<br /> document.write('</TR>')<br />}</p><p>// draw table for one of six color cube panels<br />function drawTable(blue) {<br /> // open table (one of six cube panels)<br /> document.write('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>')</p><p> // loop through all non-dithered color descripters as red hex<br /> for (var i = 0; i < 6; ++i) {<br /> drawRow(hex[i], blue)<br /> }</p><p> // close current table<br /> document.write('</TABLE>') <br />}</p><p>// draw all cube panels inside table cells<br />function drawCube() {<br /> // open table<br /> document.write('<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=1><TR>')</p><p> // loop through all non-dithered color descripters as blue hex<br /> for (var i = 0; i < 6; ++i) {<br /> // open table cell with white background color<br /> document.write('<TD BGCOLOR="#FFFFFF">')</p><p> // call function to create cube panel with hex[i] blue hex<br /> drawTable(hex[i])</p><p> // close current table cell<br /> document.write('</TD>')<br /> }</p><p> // close table row and table<br /> document.write('</TR></TABLE>')<br />}</p><p>// call function to begin execution<br />drawCube()</p><p>// --><br /></script></p><p></body><br /></html></p>
提示:您可以先修改部分代碼再運行