|
|
|
|
[HTML/JavaScript] Couleur de fond dynamique
Dernière réponse le 27 nov 2008 à 06:59:36 Maxence, le 11 avr 2007 à 15:25:45Bonjour a tous,
J'ai un ptit souci de programmation ... Je m'explique :
J'aimerais qu'en cliquant sur des images qui sont affichées sur ma page html, par exemple une image jaune, la couleur du fond de ma page prenne la couleur de l'image ...
Voila, la couleur de l'image n'est en realité que prévu pour que la personne sache quelle va etre la couleur du site apres avoir cliqué dessus.
Merci d'avance pour votre aide, et si vous voulez plus d'explications demandez moi :)
A plus ,
Maxence
Configuration: Windows XP Firefox 2.0.0.3
Salut,
|
Et bien merci tout d'abord ...
|
Salut!
<html>
<!-- Author: HackTrack -->
<head>
<title>Démo de sélection de couleur de fond</title>
<script language="javascript" type="text/javascript">
function changeBackgroundColor(elm){
window.status=elm.style.backgroundColor;
document.body.style.backgroundColor=elm.style.backgroundColor;
}
</script>
<style>
table, tr, td{
margin: 0px;
padding:0px;
border: solid 1px #0f0f0f;
}
div{
width: 50px;
height: 50px;
}
</style>
</head>
<body>
<table>
<tr>
<th colspan="4">Choisissez la couleur de fond</th>
</tr>
<tr>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #000000;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #111111;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #222222;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #333333;"></div></td>
</tr>
<tr>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #444444;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #555555;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #666666;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #777777;"></div></td>
</tr>
<tr>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #888888;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #999999;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #aaaaaa;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #bbbbbb;"></div></td>
</tr>
<tr>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #cccccc;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #dddddd;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #eeeeee;"></div></td>
<td><div onclick="javascript: changeBackgroundColor(this);" style="background-color: #ffffff;"></div></td>
</tr>
</table>
</body>
</html>
;-) HackTrack |

