Comment changer l'image de fond d'un site ???

BenjD90 Messages postés 98 Statut Membre -  
BenjD90 Messages postés 98 Statut Membre -
Bonjour,

Je cherche Comment changer la couleur de fond du site comme sur msn.com ou sur http://xpcoccinelle.fredisland.net/forum/?
En cliquant sur une image, par exemple, l'image de fond change.

J'ai déjà trouvé ce script :

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

_____________________________________________________________________________

Mais je n'arrive pas à le modifier pour changer d'image de fond (pas la couleur), j'ai essayer de mettre:
<td><div onClick="javascript: changeBackgroundImage(this);" style="background-image: url(Images/1304_2.jpg);"></div></td>

Je découvre le javasrcipt.
Configuration: Windows Vista
Firefox 3.0.1

4 réponses

  1. kilian Messages postés 8675 Date d'inscription   Statut Modérateur Dernière intervention   1 526
     
    Salut,

    Et avec ça?
    function changeBackgroundImage(elm){ 
        document.body.style.backgroundColor=elm.style.backgroundImage; 
    }
    0
  2. BenjD90 Messages postés 98 Statut Membre 1
     
    Merci, g trouvé

    <script language="javascript" type="text/javascript">
    function changeBackgroundImage(elm){
    window.status=elm.style.backgroundImage;
    document.body.style.backgroundImage=elm.style.backgroundImage;
    }
    </script>

    , tu m'as mené sur la bonne voie

    Au passage vous ne sauriez pas comment faire pour que ça ce prolonge sur la suite des pages visités ????????????

    genre avec un cookie
    0
    1. kilian Messages postés 8675 Date d'inscription   Statut Modérateur Dernière intervention   1 526
       
      Si mais il faudra manipuler un langage serveur comme Php par exemple.
      0
  3. BenjD90 Messages postés 98 Statut Membre 1
     
    dac, je vois pas trop comment faire le lien avec le php
    0
  4. BenjD90 Messages postés 98 Statut Membre 1
     
    je veux dire, je ne vois pas trop comment tu fait le lien entre javascript et php
    !!!
    0