cookie

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

.float_mask{position: fixed;z-index: 19999;display:none;width: 100%;right: 0; bottom: 0;height: 105px;_bottom: auto;_width: 100%;_position: absolute; 

_top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));} 

.float_layer{position: absolute;left: 0;top: 0;z-index: 1;width: 100%;height: 100%;background: #071828;filter: alpha(opacity=80);opacity: 0.80;} 

.float_content{ position: relative;z-index: 2;width: 1005px;height: 100%;margin: 0 auto;padding-left: 70px;} 

.float_bg, .float_close{ float: left;} 

.float_bg{position: relative;width: 820px;height: 135px;margin-top: -27px;} 

.float_slogan {position: absolute; background:#000;} 

.float_slogan{left: 0;bottom: 0;width: 800px;height: 135px;cursor: pointer;} 

.float_close{width: 60px;margin-top: 30px;} 

.float_close a {display: block;width: 53px; height: 52px; margin-left: 7px; background:#e00;-webkit-transition: all 400ms;} 

</style>

</head>

<body>

<div class="float_mask" id="float_mask"> 

    <div class="float_layer"> 

    </div> 

    <div class="float_content clearfix"> 

        <div class="float_bg"> 

            <a target="_blank" href="http://www.helloweba.com/" title='广告部分'> 

                <div class="float_slogan"><!--广告内容--></div> 

            </a> 

        </div> 

        <div class="float_close"> 

            <a onclick="closeFootAd()" href="#" title="我知道了"></a> 

        </div> 

    </div> 

</div> 

<script type="text/javascript">

window.onload = function(){ 

    if(getCookie("footad")==0){ 

        document.getElementById("float_mask").style.display="none"; 

    }else{ 

        document.getElementById("float_mask").style.display="block"; 

    } 

} 

//关闭底部广告 

function closeFootAd() { 

    document.getElementById("float_mask").style.display="none"; 

    setCookie("footad","0");  

} 

    

//设置cookie  

function setCookie(name,value){  

    var exp = new Date();   

    exp.setTime(exp.getTime() + 1*60*60*1000);//有效期1小时  

    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();  

}  

//取cookies函数  

function getCookie(name){  

    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));  

    if(arr != null) return unescape(arr[2]); return null;  

}  

</script>

</body>

</html>

 

posted @ 2015-07-29 20:59  San's养乐多大人  阅读(201)  评论(0编辑  收藏  举报