24小时弹出一个窗口的代码

<SCRIPT LANGUAGE=”javascript”>
<!– NETBEI.COM
var Time=86400; //设置每次弹出的相格的时间以秒为单位,现在是一天
function Set(){
var Then=new Date();
Then.setTime(Then.getTime()+Time*1000);
documents.cookie=”netbei=1;expires=”+Then.toGMTString();
}
var cookieString=new String(documents.cookie);
var cookieHeader=”netbei=”;
var beginPosition=cookieString.indexOf(cookieHeader);
if (beginPosition<0){
window.open(“http://bbs.netbei.com/”,””,”width=400,height=300″); //设置弹出窗口的大小
Set();
}
//–>
</SCRIPT>

2、可设置同一IP弹出窗口次数和时间的弹窗代码
<script language=javascript src=”/ads_36.js”></script>
JS文件

function GetCookie (name) {
var arg = name + “=”;
var alen = arg.length;
var clen = documents.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (documents.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = documents.cookie.indexOf(” “, i) + 1;
if (i == 0) break;
}
return null;
}

function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
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;
documents.cookie = name + “=” + escape (value) +
((expires == null) ? “” : (“; expires=” + expires.toGMTString())) +
((path == null) ? “” : (“; path=” + path)) +
((domain == null) ? “” : (“; domain=” + domain)) +
((secure == true) ? “; secure” : “”);
}

function deleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() – 1);
// This cookie is history
var cval = 0;
documents.cookie = name + “=” + cval + “; expires=” + exp.toGMTString();
}

//设置cookies时间,自己根据情况设置。
var expDays = 1;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*1*10*60*1000));

function amt(){
var count;
//var count = GetCookie(‘count’); //同一ip只显示一次
//var count;//同一ip只显示N次
//alert(count);
//count = null;
if(count == null) {
SetCookie(‘count’,’1′)
return 1
}
else{
var newcount = parseInt(count) + 1;
if(newcount<2) count=1;
SetCookie(‘count’,newcount,exp);
//deleteCookie(‘count’)
return newcount
}
}

function getCookieVal(offset) {
var endstr = documents.cookie.indexOf (“;”, offset);
if (endstr == -1)
endstr = documents.cookie.length;
return unescape(documents.cookie.substring(offset, endstr));
}
function openAds(){
var focusid=setTimeout(“focus();var popAd=window.showModelessDialog(‘http://bbs.netbei.com’,’17286′,’dialogHeight:200;dialogWidth:200;scroll:1;status:1;help:1;resizable:1;’);”,1000);
self.focus();
}
if(amt()==1)
{
openAds()
}
//–>

发表评论

您的电子邮箱地址不会被公开。