Recuperer un paramètre de l'URL courante

livemzone -  
avion-f16 Messages postés 19252 Date d'inscription   Statut Contributeur Dernière intervention   - 15 févr. 2010 à 16:02
Bonjour,
avec java-script je veux Récupérer un paramètre de l'URL courante
par exemple :
mon url courante est
http://monsite.com/index.php?x=sssss+sss&y=rrrrrr+rrrrrrrr&k=ttttttttttttttttttttt

je veux récupérer la valeur x qui est [sssss+sss]
et l'afficher comme suis

le paramètre x contient comme valeur: sssss+sss
A voir également:

2 réponses

avion-f16 Messages postés 19252 Date d'inscription   Statut Contributeur Dernière intervention   4 505
 
1
PRO_PHP Messages postés 95 Date d'inscription   Statut Membre Dernière intervention   1
 
essais ca je suis pas sur....

function getVar (nomVariable)
{
var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&"
if (infos.indexOf("#")!=-1)
infos = infos.substring(0,infos.indexOf("#"))+"&"
var variable=0 {
nomVariable = nomVariable + "="
var taille = nomVariable.length
if (infos.indexOf(nomVariable)!=-1)
variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
}
return variable
}
0