Bonjour,
Je souhaite lancer une redirection vers un fichier php via SRC= dans une
condition if (voir ci-dessous en bas du script) mais la redirection ne
fonctionne pas. Par contre la condition est bien validée car le cookie (crée
précédemment) est bien effacé par SetCookie.
Pourriez-vous me dire ce qui ne va pas ?
Merci d'avance
Steph
<SCRIPT language="javas cript" type="text/javascript">
var pathname=locati on.pathname;
var myDomain=pathna me.substring(0, pathname.lastIn dexOf('/')) +'/';
var date_exp = new Date();
var date_del = new Date();
date_exp.setTim e(date_exp.getT ime()+(3600*100 0)); // cookie de 1
heure
date_del.setTim e(date_del.getT ime()-(365*24*3600*10 00)); // Tuer le cookie
function SetCookie (name, value) {
var argv=SetCookie. arguments;
var argc=SetCookie. arguments.lengt h;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie =name+"="+escap e(value)+
((expires==null ) ? "" : (";
expires="+expir es.toGMTString( )))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain ))+
((secure==true) ? "; secure" : "");
}
function getCookieVal(of fset) {
var endstr=document .cookie.indexOf (";", offset);
if (endstr==-1)
endstr=document .cookie.length;
return unescape(docume nt.cookie.subst ring(offset, endstr));
}
function GetCookie (name) {
var arg=name+"=";
var alen=arg.length ;
var clen=document.c ookie.length;
var i=0;
while (i<clen) {
var j=i+alen;
if (document.cooki e.substring(i, j)==arg)
return getCookieVal (j);
i=document.cook ie.indexOf(" ",i)+1;
if (i==0) break;}
return null;
}
// CHECK IF INDEX VALUE SET
var index=GetCookie ("Index");
if (index!="") {
src=http://www.siteweb.com/fichier.php?par tnerID=partner;
//DELETE COOKIE
SetCookie("Inde x","",date_del, myDomain);
}
</SCRIPT>
Je souhaite lancer une redirection vers un fichier php via SRC= dans une
condition if (voir ci-dessous en bas du script) mais la redirection ne
fonctionne pas. Par contre la condition est bien validée car le cookie (crée
précédemment) est bien effacé par SetCookie.
Pourriez-vous me dire ce qui ne va pas ?
Merci d'avance
Steph
<SCRIPT language="javas cript" type="text/javascript">
var pathname=locati on.pathname;
var myDomain=pathna me.substring(0, pathname.lastIn dexOf('/')) +'/';
var date_exp = new Date();
var date_del = new Date();
date_exp.setTim e(date_exp.getT ime()+(3600*100 0)); // cookie de 1
heure
date_del.setTim e(date_del.getT ime()-(365*24*3600*10 00)); // Tuer le cookie
function SetCookie (name, value) {
var argv=SetCookie. arguments;
var argc=SetCookie. arguments.lengt h;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie =name+"="+escap e(value)+
((expires==null ) ? "" : (";
expires="+expir es.toGMTString( )))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain ))+
((secure==true) ? "; secure" : "");
}
function getCookieVal(of fset) {
var endstr=document .cookie.indexOf (";", offset);
if (endstr==-1)
endstr=document .cookie.length;
return unescape(docume nt.cookie.subst ring(offset, endstr));
}
function GetCookie (name) {
var arg=name+"=";
var alen=arg.length ;
var clen=document.c ookie.length;
var i=0;
while (i<clen) {
var j=i+alen;
if (document.cooki e.substring(i, j)==arg)
return getCookieVal (j);
i=document.cook ie.indexOf(" ",i)+1;
if (i==0) break;}
return null;
}
// CHECK IF INDEX VALUE SET
var index=GetCookie ("Index");
if (index!="") {
src=http://www.siteweb.com/fichier.php?par tnerID=partner;
//DELETE COOKIE
SetCookie("Inde x","",date_del, myDomain);
}
</SCRIPT>
Comment