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
|
<script type="text/javascript" language="javascript">
// <![CDATA[
function ecrire_cookie(nom, valeur, expires) {
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()));
}
function arguments_cookie(offset){
var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function lire_cookie(nom) {
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen){
var j=i+alen;
if (document.cookie.substring(i, j)==arg)
return arguments_cookies(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}
function openwindows()
{
window.open("voeux.html", "",
"width=800,height=600,scrollbars=0,left=" +
((screen.width - 800)/2) + ",top=" + ((screen.height - 600)/2) )
}
date=new Date;
date.setMonth(date.getMonth()+1); // expire dans un mois
ecrire_cookie("voeux", "1", date);
function test() {
voeux = lire_cookie("voeux");
if (voeux == 1) {
alert("Cookie présent");
}
else { openwindows(); }
}
// ]]>
</script> |
Partager