Comment avoir une IMAGE DE FOND DYNAMIQUE ???

Bonjour,

Je cherche Comment changer l'image de fond de mon 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 :

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

<table>
<tr>
<th colspan="4">Choisissez la couleur de fond</th>
</tr>
<tr>
<td><div onClick="javascript: changeBackgroundImage(this);" style="background-image: url(Images/1304_2.jpg);"></div></td>
<td><div onClick="javascript: changeBackgroundImage(this);" style="background-image: url(Images/1304_2.jpg);"></div></td>
<td><div onClick="javascript: changeBackgroundImage(this);" style="background-image: url(Images/1304_3.jpg);"></div></td>
<td><div onClick="javascript: changeBackgroundImage(this);" style="background-image: url(Images/planete_rouge.jpg);"></div></td>
</tr>
</table>

Le problème, c que ça ne reste pas quand on change de page, je ne voi pas comment faire pour le mettre sous forme d'un cookie ??

merci d'avance
Configuration: Windows Vista
Firefox 3.0.1

5 réponses

  • Votes
  • Date
  • Date décroissante
  1. Modérateur
    Salut,
    Tu peux éventuellement faire un styleswitcher...
    Soit en php voir ici : http://css.alsacreations.com/Tutoriels-PHP/Faire-un-Style-switcher-changement-d-habillage-en-PHP
    ou là : http://www.siteduzero.com/tutoriel-3-31678-un-style-switcher-en-php.html
    ou à l'aide de javascript : https://blogs.opera.com/news/
    personnellement j'en ai un sur mon site avec un fichier styleswitcher.js dans le répertoire racine (<script type="text/javascript" src="styleswitcher.js"></script> ), je trouve ça beau et simple à réaliser.
    @+
    1. merci, je pense que c'est ce que je cherchais, j'ais du boullot maintenant pour tout comprendre

      merci beaucoup

      ps:

      marrant ton site! , je ne te voyais pas musicien
      1. en fait, je vois pas trop comment rajouté des style à ta page de ton site web
        1. Bonsoir,

          inutile de poser la même question dans plusieurs forums.