<div class="dn car-activity-opcity"></div>
<div class="dn car-activity-module">
<a href="javascript:var bd_close;" class="close-activity" title="关闭" id="T-close-chezhujie" otitle="关闭-车主节首页弹窗" otype="button">关闭</a>
<a href="http://www.xxx.com/huiyuan/2016czj.shtml" class="car-activity-link-a" title="立即参与" id="T-lijicanyu" otitle="立即参与-车主节" otype="button" id="T-lijicanyu">立即参与</a>
<a href="http://www.xxx.com/cpchexian/campaign/zhitong/201601.shtml" class="car-activity-link-b" title="享车险福利" otitle="享车险福利-车主节" otype="button" target="_blank" id="T-xiangchexianfuli">享车险福利</a>
<a href="http://www.xxx.com/cpbaoxian/official/chezhujiehd/index.shtml" class="car-activity-link-c" title="享其他福利" otitle="享其他福利-车主节" otype="button" target="_blank" id="T-xiangqitafuli">享其他福利</a>
</div>
<script type="text/javascript">
$(".car-activity-module .close-activity").click(function(){
$(".car-activity-opcity").fadeOut();
$(".car-activity-module").fadeOut();
});
if(getCookieValue("carPopUp")!="ed"){
$(".car-activity-opcity").show();
$(".car-activity-module").show();
setCookie("carPopUp","ed",30,"/");
}
function setCookie(name,value,days,path){
var name = escape(name);
var value = escape(value);
var expires = new Date();
expires.setTime(expires.getTime() + days * 24*60*60*1000);
path = path =="" ? "":";path=" + path;
_expires = (typeof days) == "string" ? "": ";expires=" + expires.toUTCString();
// document.cookie = name + "=" + value + _expires + path;
document.cookie = name + "=" + value + path;
}
function getCookieValue(name){
var name = escape(name);
var allcookies = document.cookie;
name += "=";
var pos = allcookies.indexOf(name);
if(pos != -1){
var start = pos + name.length;
var end = allcookies.indexOf(";",start);
if(end == -1){
end = allcookies.length;
}
var value = allcookies.substring(start,end);
return unescape(value);
} else{
return "";
}
}
</script>
JS开发通过设置cookie实现第一次进入首页展示弹窗广告,再次进入隐藏广告
原文地址:http://iicoo.blog.51cto.com/10739372/1731451