supposons que l'utilisateur interdise les cookies.
sur la page "index.html" il choisit une couleur qui règle toutes les
couleurs de la page :
la variable est "color" supposons que l'utilisateur ait choisi "maroon".
comme le choix de couleur est dans une form, l'url de la page d'index
devient :
index.html?color=maroon
maintenant j'ai un menu qui renvoit à d'autres pages du site, par ex :
autre_page.xhtml
comment récupérer le "?color=maroon" ???
j'imagine que cela peut se faire en prenant l'adresse de la précédente
page quand on arrive dans "autre_page.xhtml" ???
-- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
Thierry Loiseau <loiseauthierry@free.fr> wrote:
index.html?color=maroon
Je ferais plutôt un "?color=%27maroon%27" ; %27= apostrophe
tiens, c'est curieux ça la chaine retournée n'est pas déjà une string ?
maintenant j'ai un menu qui renvoit à d'autres pages du site, par ex :
--
It's easy to play any musical instrument: all you have to do is
touch the right key at the right time and the instrument will
play itself. -- J.S. Bach
-- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
loiseauthierry
Une Bévue wrote:
Je ferais plutôt un "?color=%27maroon%27" ; %27= apostrophe
tiens, c'est curieux ça la chaine retournée n'est pas déjà une string ?
tiens au fait comme eval c'est de la programmation >>>sâle<<< j'ai lu qqpart un équivalent d'eval à partir de :
var machin= new Function("return "+<string à évaluer>+";")();
qqc dans ce goût-là (non testé)
j'ai lu ça à propos de l'évaluation d'une string json où, généralement on fait plutôt :
var o=eval("("+json+")");
-- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
Thierry Loiseau <loiseauthierry@free.fr> wrote:
Si, mais pour simuler un :
color='maroon';
via eval()
ah ouais, où avais-je la tête ?
tiens au fait comme eval c'est de la programmation >>>sâle<<< j'ai lu
qqpart un équivalent d'eval à partir de :
var machin= new Function("return "+<string à évaluer>+";")();
qqc dans ce goût-là (non testé)
j'ai lu ça à propos de l'évaluation d'une string json où, généralement
on fait plutôt :
var o=eval("("+json+")");
--
It's easy to play any musical instrument: all you have to do is
touch the right key at the right time and the instrument will
play itself. -- J.S. Bach
tiens au fait comme eval c'est de la programmation >>>sâle<<< j'ai lu qqpart un équivalent d'eval à partir de :
var machin= new Function("return "+<string à évaluer>+";")();
qqc dans ce goût-là (non testé)
j'ai lu ça à propos de l'évaluation d'une string json où, généralement on fait plutôt :
var o=eval("("+json+")");
-- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
ecm.mec
Une Bévue wrote:
tiens au fait comme eval c'est de la programmation >>>sâle<<< j'ai lu qqpart un équivalent d'eval à partir de :
Sale, si on veut, je ne l'utilise que très peu, mais parfois... ça aide.
Par exemple, pour récupérer les valeurs de variables via l'URL, rien de plus simple qu'avec eval() !!! Alors pourquoi se compliquer ? On fait avec les outils que l'on a, en JavaScript, non ?
Thierry
Une Bévue <unbewusst.sein@wortanschahung.com.invalid> wrote:
tiens au fait comme eval c'est de la programmation >>>sâle<<< j'ai lu
qqpart un équivalent d'eval à partir de :
Sale, si on veut, je ne l'utilise que très peu, mais parfois... ça aide.
Par exemple, pour récupérer les valeurs de variables via l'URL, rien de
plus simple qu'avec eval() !!! Alors pourquoi se compliquer ? On fait
avec les outils que l'on a, en JavaScript, non ?
tiens au fait comme eval c'est de la programmation >>>sâle<<< j'ai lu qqpart un équivalent d'eval à partir de :
Sale, si on veut, je ne l'utilise que très peu, mais parfois... ça aide.
Par exemple, pour récupérer les valeurs de variables via l'URL, rien de plus simple qu'avec eval() !!! Alors pourquoi se compliquer ? On fait avec les outils que l'on a, en JavaScript, non ?
Thierry
unbewusst.sein
ecm wrote:
On fait avec les outils que l'on a, en JavaScript, non ?
oui, oui...
-- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
ecm <ecm.mec@cem.ec> wrote:
On fait
avec les outils que l'on a, en JavaScript, non ?
oui, oui...
--
It's easy to play any musical instrument: all you have to do is
touch the right key at the right time and the instrument will
play itself. -- J.S. Bach
On fait avec les outils que l'on a, en JavaScript, non ?
oui, oui...
-- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
ASM
Thierry Loiseau wrote:
index.html?color=maroon Je ferais plutôt un "?color=%27maroon%27" ; %27= apostrophe
tiens, c'est curieux ça la chaine retournée n'est pas déjà une string ?
elle n'était pas sous la forme variable = 'valeur';
url = ...htm?var1=val1&var2=val2&var3=val3
var o = self.location.toString().split('?')[1]; o = o.replace(/=/g,'='')+'''; o = o.replace(/&/g,'';'); eval(o);
alert(var1+' '+var2+' '+var3);
Le eval() est ici employé à bon et sciant. (exactement comme json pourraît le faire)
ah merci, au moins cette version est plus poétique ;-) -- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach
ah merci, au moins cette version est plus poétique ;-)
--
It's easy to play any musical instrument: all you have to do is
touch the right key at the right time and the instrument will
play itself. -- J.S. Bach
ah merci, au moins cette version est plus poétique ;-) -- It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself. -- J.S. Bach