JavaScriptを使用してポップアップマネージャを作成しようとしましたが、アイディアはajaxポップアップを1回だけ表示することです。なんらかの理由で、ポップアップが2回以上ランダムに表示されます。だから何が起こっていることはこれです、Javascriptでクッキーを管理する
function SetCookie(name, value, days) {
var expire = new Date();
expire.setTime (expire.getTime() + (24 * 60 * 60 * 1000) * days);
document.cookie = name + "=" + escape(value) + "; expires=" +expire.toGMTString();
}
function GetCookie(name) {
var startIndex = document.cookie.indexOf(name);
if (startIndex != -1) {
var endIndex = document.cookie.indexOf(";", startIndex);
if (endIndex == -1) endIndex = document.cookie.length;
return unescape(document.cookie.substring(startIndex+name.length+1, endIndex));
}
else {
return null;
}
}
function DeleteCookie(name) {
var expire = new Date();
expire.setTime (expire.getTime() - (24 * 60 * 60 * 1000));
document.cookie = name + "=; expires=" + expire.toGMTString();
}
function Pop() {
var cookie = GetCookie("popup");
if(cookie==null) {
SetCookie("popup",1,300);
}
else {
if(cookie==1) {
new Ajx.Dialog();
SetCookie("popup",2,300);
return false;
}
else {
return false;
}
}
}
window.onload = Pop;
あなたは 'SetCookie'関数を定義していないようです。 – johnhunter
更新されたコードありがとうございました:) – johnhunter