begin process at 2008 08 30 00:20:37
1 233 952 membres
470 nouveaux aujourd'hui
14 294 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

CHANGER DE THEME ET DE COULEUR


Information sur la source

Description

Un exemple très simple: changer à la volé le style de votre site via une liste déroulante.
Voir un exemple sur ActuFr.com.
Compatible IE & FireFox.

Source

  • //-------- Créer le fichier : couleur.html --------//
  • <html>
  • <head>
  • <!-- Couleurs des 3 options du menu déroulant -->
  • <style>
  • .style1 { color:white; background-color:blue }
  • .style2 { color:white; background-color:red }
  • .style3 { color:white; background-color:green }
  • </style>
  • <script> // Chargement du style.css
  • StyleCss=(location.hash=="") ? 1 : eval(location.hash.substring(1,2));
  • document.write('<style>@import url(style'+StyleCss+'.css);</style>')
  • </script>
  • </head>
  • <body>
  • <form style="margin:1;" name="Fcolor">
  • <select id=ListMenu onchange="javascript:location.href=this.value;location.reload()">
  • <option class=style1 value="couleur.html#1">Thème Bleu
  • <option class=style2 value="couleur.html#2">Thème rouge
  • <option class=style3 value="couleur.html#3">Thème Vert
  • </select>
  • </form>
  • <script> // On applique la couleur de <option> à <select>
  • document.Fcolor.ListMenu.options[StyleCss-1].selected=true;
  • document.Fcolor.ListMenu.className=document.Fcolor.ListMenu.options[StyleCss-1].className;
  • </script>
  • <H1> TITRE </H1>
  • <H2> TITRE </H2>
  • <H3> TITRE </H3>
  • <H4> TITRE </H4>
  • <a href="http://actufr.com">Voir un exemple sur ActuFr.com</a>
  • </body>
  • </html>
  • //-------- Créer le fichier : style1.css --------//
  • H1 { color:#0000FF }
  • H2 { color:#5555FF }
  • H3 { color:#7777FF }
  • H4 { color:#9999FF }
  • a:link { color:#0000FF; text-decoration:none }
  • a:visited{ color:#5555FF; text-decoration:none }
  • a:hover { color:#9999FF; text-decoration:none }
  • //-------- Créer le fichier : style2.css --------//
  • H1 { color:#FF0000 }
  • H2 { color:#FF5555 }
  • H3 { color:#FF7777 }
  • H4 { color:#FF9999 }
  • a:link { color:#FF0000; text-decoration:none }
  • a:visited{ color:#FF5555; text-decoration:none }
  • a:hover { color:#FF9999; text-decoration:none }
  • //-------- Créer le fichier : style3.css --------//
  • H1 { color:#007700 }
  • H2 { color:#009900 }
  • H3 { color:#00CC00 }
  • H4 { color:#00FF00 }
  • a:link { color:#007700; text-decoration:none }
  • a:visited{ color:#009900; text-decoration:none }
  • a:hover { color:#00FF00; text-decoration:none }
//-------- Créer le fichier : couleur.html --------//
<html>
<head>
 <!-- Couleurs des 3 options du menu déroulant  -->
<style>
.style1 { color:white; background-color:blue  }
.style2 { color:white; background-color:red   }
.style3 { color:white; background-color:green }
</style>
<script> // Chargement du style.css
StyleCss=(location.hash=="") ? 1 : eval(location.hash.substring(1,2));
document.write('<style>@import url(style'+StyleCss+'.css);</style>')
</script>
</head>
<body>
<form style="margin:1;" name="Fcolor"> 
<select id=ListMenu  onchange="javascript:location.href=this.value;location.reload()">
  <option class=style1 value="couleur.html#1">Thème Bleu 
  <option class=style2 value="couleur.html#2">Thème rouge
  <option class=style3 value="couleur.html#3">Thème Vert  
</select>
</form>
<script>  // On applique la couleur de <option> à <select>
document.Fcolor.ListMenu.options[StyleCss-1].selected=true;
document.Fcolor.ListMenu.className=document.Fcolor.ListMenu.options[StyleCss-1].className;
</script>
<H1> TITRE </H1>
<H2> TITRE </H2>
<H3> TITRE </H3>
<H4> TITRE </H4>
<a href="http://actufr.com">Voir un exemple sur ActuFr.com</a>
</body>
</html>


//-------- Créer le fichier : style1.css --------//
H1 { color:#0000FF }
H2 { color:#5555FF }
H3 { color:#7777FF }
H4 { color:#9999FF }
a:link   { color:#0000FF; text-decoration:none }
a:visited{ color:#5555FF; text-decoration:none }
a:hover  { color:#9999FF; text-decoration:none }


//-------- Créer le fichier : style2.css --------//
H1 { color:#FF0000 }
H2 { color:#FF5555 }
H3 { color:#FF7777 }
H4 { color:#FF9999 }
a:link   { color:#FF0000; text-decoration:none }
a:visited{ color:#FF5555; text-decoration:none }
a:hover  { color:#FF9999; text-decoration:none }


//-------- Créer le fichier : style3.css --------//
H1 { color:#007700 }
H2 { color:#009900 }
H3 { color:#00CC00 }
H4 { color:#00FF00 }
a:link   { color:#007700; text-decoration:none }
a:visited{ color:#009900; text-decoration:none }
a:hover  { color:#00FF00; text-decoration:none }
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

  • signaler à un administrateur
    Commentaire de georges023 le 05/09/2006 01:37:03

    Super, bien fais, j'ai justement programmer un code pareil (specialement creer pour mes besoins),
    Il utilise plus de tme que celui-ci et est plus complexe et il est au aussi copyright©, lol

Ajouter un commentaire

Pub



Appels d'offres

Recherche developpeur ...
Budget : 700€
SITE MARCHAND LOCATION...
Budget : 3 000€
SITE MARCHAND POUR HOTEL
Budget : 4 000€

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

Boutique

Boutique de goodies CodeS-SourceS