对一个IP只弹出一次窗口

一个IP只弹出一次的退窗代码

<%
if session("ad")<>"ad" then
%>
<SCRIPT event=onunload for=window>
window.open(' http://www.eduyp.com')
</SCRIPT>
<%
session("ad")="ad"
end if
%>


一个IP只弹出一次代码

<script>
 
  var cookieString = new String(documents.cookie)
  var cookieHeader = 'happy_pop=' //更换happy_pop为任意名称
  var beginPosition = cookieString.indexOf(cookieHeader)
  if (beginPosition <0){
window.open(' http://你要弹出的ul','','top=0,left=0,width=787,height=480,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes');
var Then = new Date()    
   Then.setTime(Then.getTime() + 12*60*60*1000 ) //同一ip设置过期时间,即多长间隔跳出一次
   documents.cookie = 'happy_pop=yes;expires='+ Then.toGMTString()  //更换happy_pop和第4行一样的名称
    }

</script>
sethome()
}
//-->
</script>


一个IP只提示一次设为首页的代码

<script>
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*24*60*60*1000));

function amt(){
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 sethome(){
document.links[0].style.behavior='url(#default#homepage)';
document.links[0].setHomePage(' http://www.eduyp.com');
}
if(amt()==1)
{
sethome()
}
//-->
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值