cookia定时弹窗广告代码

ė 148 6 0
本文最近更新于23.01.12 周四请自行判断新内容
编者:

利用jquery.cookie.js做弹窗广告,目前测不错。可以定时弹窗,任意设置时间。


<style type="text/css">
.alert_windows{
display:none;
position:absolute;
z-index:10;
width:400px;
height:300px;
background:#566F93;
}

.alert_windows .adclose{
float:right;
width:30px;
height:30px;
text-align:center;
font:15px/30px Microsoft Yahei;
cursor:pointer;
color:#333;
background:lightblue;
}

.alert_windows .adclose:hover{
color:#EEE;
background:red;
}
</style>
<div class="alert_windows">
<span class="adclose">X</span>
</div>
<script type="text/javascript" src="https://demo.16css.com/js/piaofu/1308/js/jquery.min.js"></script>
<script type="text/javascript" src="https://demo.16css.com/js/piaofu/1308/js/jquery.cookie.js"></script>
<script type="text/javascript">
$(function(){

if($.cookie("isClose") != 'yes'){
setTimeout (function () {
var winWid = $(window).width()/2 - $('.alert_windows').width()/2;
var winHig = $(window).height()/2 - $('.alert_windows').height()/2;
$(".alert_windows").css({"left":winWid,"top":-winHig*2}); //自上而下
$(".alert_windows").show();
$(".alert_windows").animate({"left":winWid,"top":winHig},1000);
$(".alert_windows .adclose").click(function(){
$(this).parent().fadeOut(500);
$.cookie("isClose",'yes',{ expires:1/86004}); //测试十秒
//$.cookie("isClose",'yes',{ expires:1}); 一天
});
},15000); //15秒后出现广告
}
});
</script>

第一个会重复一个

<style type="text/css">
.addesc img{max-width:100%;margin:0 auto;}.addkillcont{position: fixed;width: 100%;height: 2000px;z-index: 999999;top: 0px;background: #CCC;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#BF000000,endColorstr=#00000000);background-color: rgba(103, 99, 99, 0.59);}
.addesc{position: relative;margin-left: auto;margin-right: auto;background: #FFF;border: 1px solid #CCC;webkit-box-shadow: 0 0 20px rgba(27,22,22,0.3);-moz-box-shadow: 0 0 20px rgba(27,22,22,0.3);-o-box-shadow: 0 0 20px rgba(27,22,22,0.3);box-shadow: 0 0 20px rgba(27,22,22,0.3);padding: 10px;margin-top: 10px;font-family: "Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif;}
</style>
<script type='text/javascript'>
var cookieString = new String(document.cookie)
var cookieHeader = 'happy_op=' //更换happy_pop为任意名称
var beginPosition = cookieString.indexOf(cookieHeader)
if (beginPosition <0){
$(document).ready(function(){
setTimeout(function(){new QXAdTest().init();},1);
});
function QXAdTest(){
var thisObj = this;
this.init = function(){
try{
this.DoShow();
$('.idcloseadtips').on("click",function(){
$("#idadkillsho").remove();
});
}catch(e){
$("#idadkillsho").remove();
}
};
this.DoShow =function(){
try{
var TPL='<div id="idadkillsho" class="addkillcont"><div class="addesc" id="addesc" style="display:none;max-width: 80%;text-align: center;"><div style="color:red;font-weight:bold; text-align:center;margin-bottom:10px">DUX7..0-7.3破解版</div><a href="https://www.qixibang.cc/24039.html"><img src="https://www.qixibang.cc/wp-content/uploads/2023/01/wp-1673498269802.jpg" alt="dux主题"></a><span class="idcloseadtips" style="position:absolute;right:10px;top:10px;font-weight:bold;color:gray;cursor:pointer">点此关闭</span></div></div>';
var TPLObj = $(TPL);
TPLObj.appendTo($('BODY')).hide().fadeIn(500,function(){
$("#addesc").animate({"margin-top":"150px"},600);
$("#addesc").slideDown(500,function(){
$("#addesc").animate({"min-height":"250px"},600);
$("#addesc").animate({"max-width":"80%"},600);
}
);
//自动移除弹窗代码调用
thisObj.DelayRemove();
});
}catch(e){
$("#idadkillsho").remove();//弹窗关闭按钮的调用
}
}
this.DelayRemove = function(){
setTimeout(function(){
$("#addesc").fadeOut(600,function(){
$("#idadkillsho").remove();
});
},200000);//自动移除时间,这里单位是ms
}
}
var Then = new Date()
Then.setTime(Then.getTime() + 1*60*60*1000 ) //同一ip设置过期时间,即多长间隔跳出一次
document.cookie = 'happy_op=yes;expires='+ Then.toGMTString()  //更换happy_pop和第4行一样的名称
}
</script>

这个会好点

栖息邦 收藏Ctrl+D 转载注明来源
管理员登录
注册

提示:点击上下面区域关闭

字号调整

View My Stats
空位 空位
本次加载耗时:0.296s