1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| //Je recupère le lien
var Chaine = String(window.location);
var test = 0;
//Fonction qui me coup mon URL pour récupérer les variables
function PrmUrl()
{
var prm = new Array();
var tmp =
unescape(window.location.search).substr(1).split("
&");
var inter;
for ( i=0; i<tmp.length; i++)
{
inter=tmp[i].indexOf("=");
if ( inter>=0 )
{
prm[tmp[i].substr(0,inter)]=tmp[i].substr(inter+1)
}
else {
prm[tmp[i]]="";
}
}
return prm;
}
Si il y a bien une URL
if ( window.location.search )
{
var $_GET=PrmUrl();
var tmp= "-----------------------\r\n"+
"exemple par leur noms :\r\n"+
"-----------------------\r\n"+
"\tp1 = "+$_GET["Client"]+"\r\n"+
"\tp2 = "+$_GET["id"]+"\r\n"+
"------\r\n"+
"tous :\r\n"+
"------\r\n";
for ( var n in $_GET )
{
tmp+="\t"+n+" = "+$_GET[n]+"\r\n";
}
Je passe ma variable Test à 1 pour éviter la boucle infinie voir plus bas
test = 1;
//alert ("client = " + $_GET["Client"]);
//Si je change de catalogue je vérifie que mon titre catalogue est le meme que celui que j'avais récupéré sinon je met mon test a 0
if( document.getElementById("title").value != $_GET["Client"]){
test = 0;
}
}
//Si test =0
if (test == 0)
{
//Ici je vais découpé tout mon code pour juste avoir <a href="http://www.monsite/go.php" target="_blank">www.monsite/go.php</a> et pouvoir rajouté par la suite mes variables.
var sous_chaine = "?Client=";
var Resultat = Chaine.indexOf(sous_chaine);
var Resultat2 = Chaine.substring(0,Resultat);
test = 0;
//window.location.href= Resultat2 + "?Client=" + document.getElementById("title").value;
window.location.href= Resultat2 + "?Client=" + document.getElementById("title").value + "&id=" + document.getElementById("MediaID").value;
} |
Partager