The mouse chooses the dynamic change page background color The JS code _javascript skill

Source: Internet
Author: User

Using JavaScript implementation, with the mouse click on the corresponding color, dynamic change the background color of the Web page

Here's the screenshot.

The corresponding JavaScript source code is:

Copy Code code as follows:

var hex = new Array (6)

Hex[0] = "FF"
HEX[1] = "CC"
HEX[2] = "99"
HEX[3] = "66"
HEX[4] = "33"
HEX[5] = "00"
function display (triplet) {
Document.bgcolor = ' # ' + triplet
}
function Drawcell (red, green, blue) {
document.write (' <td bgcolor= "# ' + red + green + blue + ' > ')
document.write (' <a href= "javascript:display (\ ' + (red + green + blue) + ') ' > ')
document.write (' ')
document.write (' </A> ')
document.write (' </TD> ')
}
function Drawrow (red, blue) {
document.write (' <TR> ')
for (var i = 0; i < 6; ++i) {
Drawcell (red, hex[i], blue)
}
document.write (' </TR> ')
}
function Drawtable (blue) {
document.write (' <table cellpadding=0 cellspacing=0 border=0> ')
for (var i = 0; i < 6; ++i) {
Drawrow (Hex[i], blue)
}
document.write (' </TABLE> ')
}
function Drawcube () {
document.write (' <table cellpadding=5 cellspacing=0 border=1><tr> ')
for (var i = 0; i < 6; ++i) {
document.write (' <td bgcolor= ' #FFFFFF ">")
Drawtable (Hex[i])
document.write (' </TD> ')
}
document.write (' </TR></TABLE> ')
}
Drawcube ()

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: info-contact@alibabacloud.com 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.