.打开页面自动弹出  当关闭弹框的时候  设置cookie生存时间  再次刷新页面判断cookie是否失效

<html>
<head>
<meta charset="utf-8" />
<title>LIGHTBOX EXAMPLE</title>
<style>
.black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.6; opacity:.60; filter: alpha(opacity=60); }
.white_content { display: none; position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; /*padding: 16px;*/ /*border: 16px solid orange;*/border: 1px solid grey; background-color: white; z-index:1002; /*overflow: auto; */}
</style>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> <script>
  $( document).ready(function(){
//判断cookie是否存在
if(document.cookie.length <=0){
one();
}else{
return '';
} }); function one(){
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block'
} function two(){
document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none'
//关闭弹框是设置cookie
setCookie('opop','lailailai',1800) }
//设置cookie
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
} //获取cookie
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
}
return "";
} </script> </script> </head>
<body >
<p>
<a href="javascript:showBg();" onclick="one()">点击这里打开窗口</a>
</p>
<div id="light" class="white_content">
<img src="http://imageavatar.xiangsibang.com/gfs.php?img=9cdbc343a8846bba79b55a7c523f9b4f&w=800" style="width:100%;height:100%;">
<a href="javascript:void(0)" onclick="two()" style=" color:red;margin-top: -50%; position: absolute;float: right;/* margin-right: -34%; */margin-left: 99%;">X</a>
</div>
<div id="fade" class="black_overlay" >
</div>
</body>
</html>

  

05-23 09:15