javascript实现单个IP一天只弹出一次广告的代码

发布时间:2019-08-26编辑:脚本学堂
用javascript来控制广告AD的弹出数量,单个IP一天只弹出一次,有需要的朋友,可以参考下。

代码如下:

<Script Languag="javascript"> 
/**
 * 单IP广告弹出限制
 * site http://www.jb200.com
*/
<!-- 
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("SexMovie", name, expires); 
}

var exitURL="http://www.jb200.com";
function openWin() {
  var c = getCookie("SexMovie"); 
  if (c != null) { 
    return; 
  } 
  register("9free");
  var featureStr="''";
  featureStr="'top=0,left=0,width=800,height=600,toolbar=yes, menubar=no, scrollbars=yes, resizable=yes, location=yes, status=no,center:no'";
  self.focus();
  var ExitWindow = window.open(exitURL,'', featureStr); 
  ExitWindow.focus(); 
}
openWin(); 
window.focus() 
--> 
</Script>
您还可以参考下这篇文章:javascript 一个IP只弹窗一次的实现代码