Mit Javascript implementiert, klicken Sie mit der Maus auf die entsprechende Farbe, um die Hintergrundfarbe der Webseite dynamisch zu ändern
Dies ist ein Screenshot
Der entsprechende Javascript-Quellcode lautet:
Kopieren Sie den Codecode wie folgt:
var hex = neues Array(6)
hex[0] = „FF“
hex[1] = „CC“
hex[2] = „99“
hex[3] = „66“
hex[4] = „33“
hex[5] = „00“
Funktionsanzeige (Triplett) {
document.bgColor = '#' + Triplett
}
Funktion drawCell(rot, grün, blau) {
document.write('<TD BGCOLOR="#' + rot + grün + blau + '">')
document.write('<A HREF="javascript:display(/'' + (rot + grün + blau) + '/')">')
document.write('<IMG SRC="place.gif" BORDER=0 HEIGHT=12 WIDTH=12>')
document.write('</A>')
document.write('</TD>')
}
Funktion drawRow(rot, blau) {
document.write('<TR>')
für (var i = 0; i < 6; ++i) {
drawCell(rot, hex[i], blau)
}
document.write('</TR>')
}
Funktion drawTable(blue) {
document.write('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>')
für (var i = 0; i < 6; ++i) {
drawRow(hex[i], blau)
}
document.write('</TABLE>')
}
Funktion drawCube() {
document.write('<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=1><TR>')
für (var i = 0; i < 6; ++i) {
document.write('<TD BGCOLOR="#FFFFFF">')
drawTable(hex[i])
document.write('</TD>')
}
document.write('</TR></TABLE>')
}
drawCube()