html网页弹窗代码(一个IP24小时只弹一次),如果想改时间请修改代码中的1000*60*60*24,把24改成几就是几小时弹一次了,第一框的是HMTL代码,直接放入HTML源码中就可以了,第二框的是JS代码,放在JS文件中,在网页中调用JS文件就可以了,已测试可用。记得修改你要弹出的网址替换代码中的
function setCookie(name, value, expire) {
window.document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}
function getCookie(Name) {
var search = Name + "=";
if (window.document.cookie.length > 0) { // if there are any cookies
offset = window.document.cookie.indexOf(search);
if (offset != -1) { // if cookie exists
offset += search.length;
// set index of beginning of value
end = window.document.cookie.indexOf(";", offset)
// set index of end of cookie value
if (end == -1)
end = window.document.cookie.length;
return unescape(window.document.cookie.substring(offset, end));
}
}
return null;
}
function register(name) {
var today = new Date();
var expires = new Date();
expires.setTime(today.getTime() + 1000*60*60*24);
setCookie("ItDoor", name, expires);
}
var exitURL="/";
function openWin() {
var c = getCookie("ItDoor");
if (c != null) {
return;
}
register("xiaolin");
var featureStr="''";
featureStr="'top=0,left=0,width=800,height=600,toolbar=yes, menubar=no, scrollbars=no, resizable=no, location=no, status=no,center:no'";
self.focus();
var ExitWindow = window.open(exitURL,'', featureStr);
ExitWindow.focus();
}
openWin();
window.focus()
document.writeln("
document.writeln("function setCookie(name, value, expire) { ");
document.writeln(" window.document.cookie = name + \"=\" + escape(value) + ((expire == null) ? \"\" : (\"; expires=\" + expire.toGMTString())); ");
document.writeln("} ");
document.writeln("");
document.writeln("function getCookie(Name) { ");
document.writeln(" var search = Name + \"=\"; ");
document.writeln(" if (window.document.cookie.length > 0) { \/\/ if there are any cookies ");
document.writeln(" offset = window.document.cookie.indexOf(search); ");
document.writeln(" if (offset != -1) { \/\/ if cookie exists ");
document.writeln(" offset += search.length;");
document.writeln("\/\/ set index of beginning of value ");
document.writeln(" end = window.document.cookie.indexOf(\";\", offset) ");
document.writeln("\/\/ set index of end of cookie value");
document.writeln(" if (end == -1)");
document.writeln(" end = window.document.cookie.length;");
document.writeln(" return unescape(window.document.cookie.substring(offset, end));");
document.writeln(" }");
document.writeln(" }");
document.writeln(" return null;");
document.writeln("}");
document.writeln("function register(name) {");
document.writeln(" var today = new Date();");
document.writeln(" var expires = new Date();");
document.writeln(" expires.setTime(today.getTime() + 1000*60*60*24);");
document.writeln(" setCookie(\"ItDoor\", name, expires);");
document.writeln("}");
document.writeln(" var exitURL=\"http:\/\/\/\";");
document.writeln("function openWin() {");
document.writeln("");
document.writeln(" var c = getCookie(\"ItDoor\");");
document.writeln(" if (c != null) {");
document.writeln(" return;");
document.writeln(" }");
document.writeln(" register(\"xiaolin\");");
document.writeln(" ");
document.writeln(" var featureStr=\"\'\'\";");
document.writeln(" ");
document.writeln(" featureStr=\"\'top=0,left=0,width=800,height=600,toolbar=yes, menubar=no, scrollbars=no, resizable=no, location=no, status=no,center:no\'\";");
document.writeln("");
document.writeln(" ");
document.writeln(" self.focus();");
document.writeln(" ");
document.writeln(" var ExitWindow = window.open(exitURL,\'\', featureStr);");
document.writeln(" ExitWindow.focus();");
document.writeln(" ");
document.writeln("}");
document.writeln("openWin();");
document.writeln("window.focus()");
document.writeln("<\/Script>")