bonjour...
je débute dans l'écriture du script et je me retrouve face a un problème
que je ne comprend pas...
le script fonctionne correctement tant que je ne vais pas rechercher de
valeur dans un cookie...
pas moyen de le faire a partir des valeurs reprise dans le cookie...
bonjour...
je débute dans l'écriture du script et je me retrouve face a un problème
que je ne comprend pas...
le script fonctionne correctement tant que je ne vais pas rechercher de
valeur dans un cookie...
pas moyen de le faire a partir des valeurs reprise dans le cookie...
bonjour...
je débute dans l'écriture du script et je me retrouve face a un problème
que je ne comprend pas...
le script fonctionne correctement tant que je ne vais pas rechercher de
valeur dans un cookie...
pas moyen de le faire a partir des valeurs reprise dans le cookie...
mauvaise manipulation...
je continue...
donc si j'appelle une fonction de changement de couleur de texte avec
unbouton, ça fonctionne très bien...
mais pas si la valeur vient du script...
les valeurs de mes variables sont pourtant bonnes, j'ai mis des "alert" pour
les vérifier...
si qlqu'un peut me corriger ça, j'attend les critiques avec impatience...
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
var couleur_fond
var couleur_texte
function enregistrer(coule) {
var aujourdhui = new Date();
var expiration = new Date();
// la date d'expiration du cookie en millisecondes : ici, 2 minutes, pour
l'exemple
expiration.setTime(aujourdhui.getTime() + 1000*60*2);
if(couleur_fond==null)
{couleur_fond="#FFFFFF"}
if(couleur_texte==null)
{couleur_texte="#000000"}
placer_cookie("couleur", couleur_fond,couleur_texte, expiration)
}
function placer_cookie(nom, valeur_fond,valeur_texte, expire) {
alert("couleur_fond="+couleur_fond+"n"+"couleur_texte="+couleur_texte)
document.cookie = nom + "=" +"_fond"+ escape(valeur_fond)+"_texte"+
escape(valeur_texte) + ((expire == null) ? "" : ("_ expires=" +
expire.toGMTString()))
}
function lire_cookie(nom) {
var recherche = nom;
if (document.cookie.length > 0) {
debut = document.cookie.indexOf(recherche);
if (debut != -1) {
debut += recherche.length;
fin = document.cookie.indexOf("_", debut);
if (fin == -1) {
fin = document.cookie.length;
}
couleur_fond=document.cookie.substring(debut, fin)
return unescape(document.cookie.substring(debut, fin));
}
}
}
function modif_fond(coule)
{if(coule!=couleur_texte)
{document.bgColor=coule;
couleur_fond=coule
enregistrer()}
else
{alert("vous ne saurez rien lire...")}
}
function modif_texte(cotext)
{if(cotext!=couleur_fond){
alert(cotext)
document.all.test.style.color=cotext
couleur_texte=cotext
enregistrer()}
else
{alert("vous ne saurez rien lire...")}
}
//-->
</script>
<style type="text/css">
<!--
#test {
color: #000000;
font-size: 36px;
}
-->
</style>
</head>
<body>
<script>
var gateau = lire_cookie("fond");
var cake = lire_cookie("texte")
if (gateau != null) {
alert("gateau="+gateau+"n"+"cake="+cake)
couleur_fond=gateau
couleur_texteÊke
modif_fond(gateau)
//il suffit de supprimer la ligne suivante pour ne plus avoir d'erreur...
modif_texte(cake)
}
</script>
<table border="0" cellspacing="0">
<tr>
<td bgcolor="#FFFF00"><a href="javascript:modif_fond('#FFFF00')"><img
src="images/jaune.gif" width="36" height="36"></a></td>
<td bgcolor="#ff0000"><a href="javascript:modif_fond('#ff0000')"><img
src="images/rouge.gif" width="36" height="36"></a></td>
<td bgcolor="#00FF00"><a href="javascript:modif_fond('#00ff00')"><img
src="images/vert.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#add8e6"><a href="javascript:modif_fond('lightblue')"><img
src="images/bleu_clair.gif" width="36" height="36"></a></td>
<td bgcolor="#CC3333"><a href="javascript:modif_fond('#CC3333')"><img
src="images/rouille.gif" width="36" height="36"></a></td>
<td bgcolor="#FF99CC"><a href="javascript:modif_fond('#FF99CC')"><img
src="images/rose.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#573498" ><a href="javascript:modif_fond('#573498')"><img
src="images/mauve.gif" width="36" height="36"></a></td>
<td bgcolor="#FF9966"><a href="javascript:modif_fond('#FF9966')"><img
src="images/orange.gif" width="36" height="36"></a></td>
<td bgcolor="#CCFFCC"><a href="javascript:modif_fond('#CCFFCC')"><img
src="images/vert_d_eau.gif" width="36" height="36"></a></td>
</tr>
</table>
<p>
<div id='test'>test de texte </div>
</p>
<table border="0" cellspacing="0">
<tr>
<td bgcolor="#FFFF00"><a href="javascript:modif_texte('#FFFF00')"><img
src="images/jaune.gif" width="36" height="36"></a></td>
<td bgcolor="#ff0000"><a href="javascript:modif_texte('#ff0000')"><img
src="images/rouge.gif" width="36" height="36"></a></td>
<td bgcolor="#00FF00"><a href="javascript:modif_texte('#00ff00')"><img
src="images/vert.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#add8e6"><a href="javascript:modif_texte('lightblue')"><img
src="images/bleu_clair.gif" width="36" height="36"></a></td>
<td bgcolor="#CC3333"><a href="javascript:modif_texte('#CC3333')"><img
src="images/rouille.gif" width="36" height="36"></a></td>
<td bgcolor="#FF99CC"><a href="javascript:modif_texte('#FF99CC')"><img
src="images/rose.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#573498" ><a href="javascript:modif_texte('#573498')"><img
src="images/mauve.gif" width="36" height="36"></a></td>
<td bgcolor="#FF9966"><a href="javascript:modif_texte('#FF9966')"><img
src="images/orange.gif" width="36" height="36"></a></td>
<td bgcolor="#CCFFCC"><a href="javascript:modif_texte('#CCFFCC')"><img
src="images/vert_d_eau.gif" width="36" height="36"></a></td>
</tr>
</table>
</body>
</html>
"Faon" a écrit dans le message de news:
4162ebdc$0$22075$bonjour...
je débute dans l'écriture du script et je me retrouve face a un problème
que je ne comprend pas...
le script fonctionne correctement tant que je ne vais pas rechercher de
valeur dans un cookie...
pas moyen de le faire a partir des valeurs reprise dans le cookie...
mauvaise manipulation...
je continue...
donc si j'appelle une fonction de changement de couleur de texte avec
unbouton, ça fonctionne très bien...
mais pas si la valeur vient du script...
les valeurs de mes variables sont pourtant bonnes, j'ai mis des "alert" pour
les vérifier...
si qlqu'un peut me corriger ça, j'attend les critiques avec impatience...
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
var couleur_fond
var couleur_texte
function enregistrer(coule) {
var aujourdhui = new Date();
var expiration = new Date();
// la date d'expiration du cookie en millisecondes : ici, 2 minutes, pour
l'exemple
expiration.setTime(aujourdhui.getTime() + 1000*60*2);
if(couleur_fond==null)
{couleur_fond="#FFFFFF"}
if(couleur_texte==null)
{couleur_texte="#000000"}
placer_cookie("couleur", couleur_fond,couleur_texte, expiration)
}
function placer_cookie(nom, valeur_fond,valeur_texte, expire) {
alert("couleur_fond="+couleur_fond+"n"+"couleur_texte="+couleur_texte)
document.cookie = nom + "=" +"_fond"+ escape(valeur_fond)+"_texte"+
escape(valeur_texte) + ((expire == null) ? "" : ("_ expires=" +
expire.toGMTString()))
}
function lire_cookie(nom) {
var recherche = nom;
if (document.cookie.length > 0) {
debut = document.cookie.indexOf(recherche);
if (debut != -1) {
debut += recherche.length;
fin = document.cookie.indexOf("_", debut);
if (fin == -1) {
fin = document.cookie.length;
}
couleur_fond=document.cookie.substring(debut, fin)
return unescape(document.cookie.substring(debut, fin));
}
}
}
function modif_fond(coule)
{if(coule!=couleur_texte)
{document.bgColor=coule;
couleur_fond=coule
enregistrer()}
else
{alert("vous ne saurez rien lire...")}
}
function modif_texte(cotext)
{if(cotext!=couleur_fond){
alert(cotext)
document.all.test.style.color=cotext
couleur_texte=cotext
enregistrer()}
else
{alert("vous ne saurez rien lire...")}
}
//-->
</script>
<style type="text/css">
<!--
#test {
color: #000000;
font-size: 36px;
}
-->
</style>
</head>
<body>
<script>
var gateau = lire_cookie("fond");
var cake = lire_cookie("texte")
if (gateau != null) {
alert("gateau="+gateau+"n"+"cake="+cake)
couleur_fond=gateau
couleur_texteÊke
modif_fond(gateau)
//il suffit de supprimer la ligne suivante pour ne plus avoir d'erreur...
modif_texte(cake)
}
</script>
<table border="0" cellspacing="0">
<tr>
<td bgcolor="#FFFF00"><a href="javascript:modif_fond('#FFFF00')"><img
src="images/jaune.gif" width="36" height="36"></a></td>
<td bgcolor="#ff0000"><a href="javascript:modif_fond('#ff0000')"><img
src="images/rouge.gif" width="36" height="36"></a></td>
<td bgcolor="#00FF00"><a href="javascript:modif_fond('#00ff00')"><img
src="images/vert.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#add8e6"><a href="javascript:modif_fond('lightblue')"><img
src="images/bleu_clair.gif" width="36" height="36"></a></td>
<td bgcolor="#CC3333"><a href="javascript:modif_fond('#CC3333')"><img
src="images/rouille.gif" width="36" height="36"></a></td>
<td bgcolor="#FF99CC"><a href="javascript:modif_fond('#FF99CC')"><img
src="images/rose.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#573498" ><a href="javascript:modif_fond('#573498')"><img
src="images/mauve.gif" width="36" height="36"></a></td>
<td bgcolor="#FF9966"><a href="javascript:modif_fond('#FF9966')"><img
src="images/orange.gif" width="36" height="36"></a></td>
<td bgcolor="#CCFFCC"><a href="javascript:modif_fond('#CCFFCC')"><img
src="images/vert_d_eau.gif" width="36" height="36"></a></td>
</tr>
</table>
<p>
<div id='test'>test de texte </div>
</p>
<table border="0" cellspacing="0">
<tr>
<td bgcolor="#FFFF00"><a href="javascript:modif_texte('#FFFF00')"><img
src="images/jaune.gif" width="36" height="36"></a></td>
<td bgcolor="#ff0000"><a href="javascript:modif_texte('#ff0000')"><img
src="images/rouge.gif" width="36" height="36"></a></td>
<td bgcolor="#00FF00"><a href="javascript:modif_texte('#00ff00')"><img
src="images/vert.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#add8e6"><a href="javascript:modif_texte('lightblue')"><img
src="images/bleu_clair.gif" width="36" height="36"></a></td>
<td bgcolor="#CC3333"><a href="javascript:modif_texte('#CC3333')"><img
src="images/rouille.gif" width="36" height="36"></a></td>
<td bgcolor="#FF99CC"><a href="javascript:modif_texte('#FF99CC')"><img
src="images/rose.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#573498" ><a href="javascript:modif_texte('#573498')"><img
src="images/mauve.gif" width="36" height="36"></a></td>
<td bgcolor="#FF9966"><a href="javascript:modif_texte('#FF9966')"><img
src="images/orange.gif" width="36" height="36"></a></td>
<td bgcolor="#CCFFCC"><a href="javascript:modif_texte('#CCFFCC')"><img
src="images/vert_d_eau.gif" width="36" height="36"></a></td>
</tr>
</table>
</body>
</html>
"Faon" <bs863038@hotmail.com> a écrit dans le message de news:
4162ebdc$0$22075$ba620e4c@news.skynet.be...
bonjour...
je débute dans l'écriture du script et je me retrouve face a un problème
que je ne comprend pas...
le script fonctionne correctement tant que je ne vais pas rechercher de
valeur dans un cookie...
pas moyen de le faire a partir des valeurs reprise dans le cookie...
mauvaise manipulation...
je continue...
donc si j'appelle une fonction de changement de couleur de texte avec
unbouton, ça fonctionne très bien...
mais pas si la valeur vient du script...
les valeurs de mes variables sont pourtant bonnes, j'ai mis des "alert" pour
les vérifier...
si qlqu'un peut me corriger ça, j'attend les critiques avec impatience...
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
var couleur_fond
var couleur_texte
function enregistrer(coule) {
var aujourdhui = new Date();
var expiration = new Date();
// la date d'expiration du cookie en millisecondes : ici, 2 minutes, pour
l'exemple
expiration.setTime(aujourdhui.getTime() + 1000*60*2);
if(couleur_fond==null)
{couleur_fond="#FFFFFF"}
if(couleur_texte==null)
{couleur_texte="#000000"}
placer_cookie("couleur", couleur_fond,couleur_texte, expiration)
}
function placer_cookie(nom, valeur_fond,valeur_texte, expire) {
alert("couleur_fond="+couleur_fond+"n"+"couleur_texte="+couleur_texte)
document.cookie = nom + "=" +"_fond"+ escape(valeur_fond)+"_texte"+
escape(valeur_texte) + ((expire == null) ? "" : ("_ expires=" +
expire.toGMTString()))
}
function lire_cookie(nom) {
var recherche = nom;
if (document.cookie.length > 0) {
debut = document.cookie.indexOf(recherche);
if (debut != -1) {
debut += recherche.length;
fin = document.cookie.indexOf("_", debut);
if (fin == -1) {
fin = document.cookie.length;
}
couleur_fond=document.cookie.substring(debut, fin)
return unescape(document.cookie.substring(debut, fin));
}
}
}
function modif_fond(coule)
{if(coule!=couleur_texte)
{document.bgColor=coule;
couleur_fond=coule
enregistrer()}
else
{alert("vous ne saurez rien lire...")}
}
function modif_texte(cotext)
{if(cotext!=couleur_fond){
alert(cotext)
document.all.test.style.color=cotext
couleur_texte=cotext
enregistrer()}
else
{alert("vous ne saurez rien lire...")}
}
//-->
</script>
<style type="text/css">
<!--
#test {
color: #000000;
font-size: 36px;
}
-->
</style>
</head>
<body>
<script>
var gateau = lire_cookie("fond");
var cake = lire_cookie("texte")
if (gateau != null) {
alert("gateau="+gateau+"n"+"cake="+cake)
couleur_fond=gateau
couleur_texteÊke
modif_fond(gateau)
//il suffit de supprimer la ligne suivante pour ne plus avoir d'erreur...
modif_texte(cake)
}
</script>
<table border="0" cellspacing="0">
<tr>
<td bgcolor="#FFFF00"><a href="javascript:modif_fond('#FFFF00')"><img
src="images/jaune.gif" width="36" height="36"></a></td>
<td bgcolor="#ff0000"><a href="javascript:modif_fond('#ff0000')"><img
src="images/rouge.gif" width="36" height="36"></a></td>
<td bgcolor="#00FF00"><a href="javascript:modif_fond('#00ff00')"><img
src="images/vert.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#add8e6"><a href="javascript:modif_fond('lightblue')"><img
src="images/bleu_clair.gif" width="36" height="36"></a></td>
<td bgcolor="#CC3333"><a href="javascript:modif_fond('#CC3333')"><img
src="images/rouille.gif" width="36" height="36"></a></td>
<td bgcolor="#FF99CC"><a href="javascript:modif_fond('#FF99CC')"><img
src="images/rose.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#573498" ><a href="javascript:modif_fond('#573498')"><img
src="images/mauve.gif" width="36" height="36"></a></td>
<td bgcolor="#FF9966"><a href="javascript:modif_fond('#FF9966')"><img
src="images/orange.gif" width="36" height="36"></a></td>
<td bgcolor="#CCFFCC"><a href="javascript:modif_fond('#CCFFCC')"><img
src="images/vert_d_eau.gif" width="36" height="36"></a></td>
</tr>
</table>
<p>
<div id='test'>test de texte </div>
</p>
<table border="0" cellspacing="0">
<tr>
<td bgcolor="#FFFF00"><a href="javascript:modif_texte('#FFFF00')"><img
src="images/jaune.gif" width="36" height="36"></a></td>
<td bgcolor="#ff0000"><a href="javascript:modif_texte('#ff0000')"><img
src="images/rouge.gif" width="36" height="36"></a></td>
<td bgcolor="#00FF00"><a href="javascript:modif_texte('#00ff00')"><img
src="images/vert.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#add8e6"><a href="javascript:modif_texte('lightblue')"><img
src="images/bleu_clair.gif" width="36" height="36"></a></td>
<td bgcolor="#CC3333"><a href="javascript:modif_texte('#CC3333')"><img
src="images/rouille.gif" width="36" height="36"></a></td>
<td bgcolor="#FF99CC"><a href="javascript:modif_texte('#FF99CC')"><img
src="images/rose.gif" width="36" height="36"></a></td>
</tr>
<tr>
<td bgcolor="#573498" ><a href="javascript:modif_texte('#573498')"><img
src="images/mauve.gif" width="36" height="36"></a></td>
<td bgcolor="#FF9966"><a href="javascript:modif_texte('#FF9966')"><img
src="images/orange.gif" width="36" height="36"></a></td>
<td bgcolor="#CCFFCC"><a href="javascript:modif_texte('#CCFFCC')"><img
src="images/vert_d_eau.gif" width="36" height="36"></a></td>
</tr>
</table>
</body>
</html>
"Faon" a écrit dans le message de news:
4162ebdc$0$22075$bonjour...
je débute dans l'écriture du script et je me retrouve face a un problème
que je ne comprend pas...
le script fonctionne correctement tant que je ne vais pas rechercher de
valeur dans un cookie...
pas moyen de le faire a partir des valeurs reprise dans le cookie...