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