求同一IP每天控制弹窗一次的JS代码 15
问题描述:例如同一根域名:abc.com四个子域名:a.abc.com,b.abc.com,c.abc.com,d.abc.com用如下代码出现的问题是,访问四个子域名的...
问题描述:
例如同一根域名:abc.com
四个子域名:a.abc.com, b.abc.com, c.abc.com, d.abc.com
用如下代码出现的问题是,访问四个子域名的时候,都弹出一次窗,
我想要的效果是,访问了四个子域名中任何的一个后,再访问其他的三个子域名都不再弹出窗口。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
function getObj(id) {
return document.getElementById(id);
}
function ietruebody() {
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
timePopup=1000;
var ns = (document.layers);
var ie = (document.all);
var w3 = (document.getElementById && !ie);
adCount = 0;
function initPopup() {
if (!ns && !ie && !w3) {
return;
}
adDiv = getObj("windlocation").style;
if (ie||w3) {
adDiv.visibility="visible";
} else {
adDiv.visibility ="show";
}
showPopup();
}
function showPopup() {
if (adCount < timePopup * 10) {
adCount+=1;
if (ie) {
documentWidth = ietruebody().offsetWidth/2+ietruebody().scrollLeft-20;
documentHeight = ietruebody().offsetHeight/2+ietruebody().scrollTop-20;
} else if (ns) {
documentWidth = window.innerWidth/2+window.pageXOffset-20;
documentHeight = window.innerHeight/2+window.pageYOffset-20;
} else if (w3) {
documentWidth = self.innerWidth/2+window.pageXOffset-20;
documentHeight = self.innerHeight/2+window.pageYOffset-20;
}
adDiv.left = documentWidth-250 + 'px';
adDiv.top = documentHeight-150 + 'px';
setTimeout("showPopup()",100);
} else {
closePopup();
}
}
function closePopup(){
if (ie||w3) {
adDiv.display = "none";
} else {
adDiv.visibility = "hide";
}
}
onload=initPopup;
function sg(){
var Then = new Date();
Then.setTime(Then.getTime() + 6*60*60*10);
var cookieString = new String(document.cookie);
var cookieHeader = "Cookie1=";
var beginPosition = cookieString.indexOf(cookieHeader);
if (beginPosition != -1){
} else {
document.cookie = "Cookie1=Filter;expires="+ Then.toGMTString()
document.writeln("<div id=\"windlocation\" style=\"position:absolute;visibility:hidden;height:1;width:1;top:50;left:50;z-index:9999;background:none;\"><script type=\"text\/javascript\" src=\"http:\/\/www.baidu.com\"><\/script>");
}
}
sg();
</script>
</body>
</html> 展开
例如同一根域名:abc.com
四个子域名:a.abc.com, b.abc.com, c.abc.com, d.abc.com
用如下代码出现的问题是,访问四个子域名的时候,都弹出一次窗,
我想要的效果是,访问了四个子域名中任何的一个后,再访问其他的三个子域名都不再弹出窗口。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
function getObj(id) {
return document.getElementById(id);
}
function ietruebody() {
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
timePopup=1000;
var ns = (document.layers);
var ie = (document.all);
var w3 = (document.getElementById && !ie);
adCount = 0;
function initPopup() {
if (!ns && !ie && !w3) {
return;
}
adDiv = getObj("windlocation").style;
if (ie||w3) {
adDiv.visibility="visible";
} else {
adDiv.visibility ="show";
}
showPopup();
}
function showPopup() {
if (adCount < timePopup * 10) {
adCount+=1;
if (ie) {
documentWidth = ietruebody().offsetWidth/2+ietruebody().scrollLeft-20;
documentHeight = ietruebody().offsetHeight/2+ietruebody().scrollTop-20;
} else if (ns) {
documentWidth = window.innerWidth/2+window.pageXOffset-20;
documentHeight = window.innerHeight/2+window.pageYOffset-20;
} else if (w3) {
documentWidth = self.innerWidth/2+window.pageXOffset-20;
documentHeight = self.innerHeight/2+window.pageYOffset-20;
}
adDiv.left = documentWidth-250 + 'px';
adDiv.top = documentHeight-150 + 'px';
setTimeout("showPopup()",100);
} else {
closePopup();
}
}
function closePopup(){
if (ie||w3) {
adDiv.display = "none";
} else {
adDiv.visibility = "hide";
}
}
onload=initPopup;
function sg(){
var Then = new Date();
Then.setTime(Then.getTime() + 6*60*60*10);
var cookieString = new String(document.cookie);
var cookieHeader = "Cookie1=";
var beginPosition = cookieString.indexOf(cookieHeader);
if (beginPosition != -1){
} else {
document.cookie = "Cookie1=Filter;expires="+ Then.toGMTString()
document.writeln("<div id=\"windlocation\" style=\"position:absolute;visibility:hidden;height:1;width:1;top:50;left:50;z-index:9999;background:none;\"><script type=\"text\/javascript\" src=\"http:\/\/www.baidu.com\"><\/script>");
}
}
sg();
</script>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询