场景:

这个是一对门户的对联广告,本文解析的是点击关闭之后刷新文章不会在出现广告,利用游览器的缓存直接处理

<div id=”ceshi”>
<div class=”piaofu-left”><span class=”piaofu-left-biaoshi”>广告</span><span class=”guanbi”>× 关闭</span><a href=””><img src=”http://www.zhicheng.com/statics/aimg/dl.gif” alt=””></a></div>
<div class=”piaofu-right”><span class=”piaofu-left-biaoshi”>广告</span><span class=”guanbi”>× 关闭</span><a href=””><img src=”http://www.zhicheng.com/statics/aimg/dl.gif” alt=””></a></div>
<style type=”text/css”>
.piaofu-left {position: fixed;top: 50%;left: 50%;margin-left:610px;margin-top: -324px;}
.piaofu-right {position: fixed;top: 50%;right: 50%;margin-right:690px;margin-top: -324px;}
.piaofu-left img,.piaofu-right img {display: block;}
.piaofu-left-biaoshi {width:30px;font-size: 12px;position: absolute;top:0px;right: 0px;text-align: center;color:#fff;height: 20px;line-height: 20px;}
.guanbi {width:95%;font-size: 12px;position: absolute;bottom:-20px;right: 0px;height: 20px;line-height: 20px;text-align: right;background: #fff;color: #666;border: #dedede solid 1px;padding-right: 5%;cursor: pointer;border-top: none}
</style>
</div>

<script type=”text/javascript”>
$(“.guanbi”).click(function(){
kaiguan();
sessionStorage.clickcount=”1″
})
function kaiguan(){
$(“#ceshi”).remove()
}

if (sessionStorage.clickcount == 1) {
$(“#ceshi”).remove()
}else {
alert(“还没有缓存条件”)
};
</script>

<div class=”w1200″><div id=”result”></div></div>
<style type=”text/css”>
.w1200{width: 1200px;height: 2000px;background: #ff6a00;margin: auto;}
</style>