JavaScript special effect instance 012-web page color picker, javascript012-

Source: Internet
Author: User

JavaScript special effect instance 012-web page color picker, javascript012-
Instance 012 web page color picker instance description in the website, you often need to customize the color to display some information. This can be achieved by adding a color picker on the webpage. Technical points in this example only use 216 browser security colors, the so-called Netscape Color Block. These 216 colors represent the values 0, 51, 102, 153, and 204 respectively, and each primary color (red, green, and blue ). The hexadecimal numbers corresponding to these decimal values are 0x00, 0x33, 0x66, 0x99, 0xCC, and 0xFF. In the HTML color attribute, black is #000000, pure red is # FF0000, pure green is #00FF00, pure blue is # 0000FF, and white is # FFFFFF. The JavaScript array must be applied to the web page color picker. You can create an array in the following three methods. (1) No parameter call.

<span style="white-space:pre"></span>var h = new Array()
(2) specify the value of the first n elements of the Array var h = new Array (arglist) (3) specify the number of elements var h = new array(n) (( 1) indexindexindex.html)
<!DOCTYPE html>(2)color.html
<script language="javascript">var h = new Array(6);h[0] = "FF";h[1] = "CC";h[2] = "99";h[3] = "66";h[4] = "33";h[5] = "00";function action(RGB){parent.window.returnValue = "#"+RGB;window.close();}function Mcell(R,G,B){document.write('<td bgcolor="#'+R+G+B+'">');document.write('<a href="#" onclick="action(\''+(R+G+B)+'\')">');document.write('');document.write('</a>');document.write('</td>');}function Mtr(R,B){document.write('<tr>');for (var i = 0; i <6; ++i){Mcell( R , h[i] , B );}document.write('</tr>');}function Mtable(B){document.write('<table cellpadding=0 cellspacing=0 border=0>');for(var i = 0;i<6;++i){Mtr(h[i],B);}document.write('</table>')}function Mcube(){document.write('<table cellpadding=0 cellspacing=0 border=0>');for(var i = 0;i<6;++i){if(i%3 == 0){document.write('<tr>')}document.write('<td bgcolor=#000000">');Mtable(h[i]);document.write('</td>')if(i%3==2){document.write('</tr>')}}document.write('</table>');}Mcube();</script>
Note: The content of the style label is css. We focus on the content in the script label. In this way, our instance is ready.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.