|
珍藏代码,一个IP只弹一次网页代码 2006-6-22 14:48:54 一个IP只弹出一次的退窗代码 CODE:[Copy to clipboard]<% if session("ad")<>"ad" then %> <SCRIPT event=onunload for=window> window.open(‘http://www.yu163.com/‘) </SCRIPT> <% session("ad")="ad" end if %> 一个IP只弹出一次代码 CODE:[Copy to clipboard]<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只提示一次设为首页的代码 CODE:[Copy to clipboard]<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.yu163.com/‘); } if(amt()==1) { sethome() } //--> </script> |