技术教程
当前位置:首页 > 技术教程

js弹窗代码24小时内只弹出一次

( 更新:04-10   加入收藏)

<script language="JavaScript" type="text/javascript"> 
function cookieGO(name) {
  var today = new Date();
  var expires = new Date();
  expires.setTime(today.getTime() + 1000*60*60*24);
  setCookie("cookievalue", name, expires);
}

function setCookie(name, value, expire) {   
  window.document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function getCookie(Name) {   
   var findcookie = Name + "=";
   if (window.document.cookie.length > 0) { // if there are any cookies
     offset = window.document.cookie.indexOf(findcookie);
  if (offset != -1) { // if cookie exists
       offset += findcookie.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 TanChuang() {
  var c = getCookie("cookievalue");
  //alert(c);
  if (c != null) {
    return;
  }
  cookieGO("getcookie");
  
    /** var featureStr="''";
  featureStr="'top=0,left=0,width=600,height=800,toolbar=yes, menubar=no, scrollbars=no, resizable=no, location=no, status=no,center:no'";
  self.focus();
  var ExitWindow = window.open(exitURL,'', featureStr);
  ExitWindow.focus();**/
  window.location.href = exitURL;
  
}
var exitURL="https://fuli.qianqi.net";

setTimeout("TanChuang()",2000);
window.focus()
</script>

相关阅读