信息彈窗提示一天只彈出一次js代碼,通過jquery.cookie.js實現(xiàn)功能,避免重復彈出。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>彈窗提示</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
.alert_windows{
display:none;
position:absolute;
z-index:10;
width:400px;
height:300px;
background:#566F93;
}
.alert_windows span{
float:right;
width:30px;
height:30px;
text-align:center;
font:15px/30px Microsoft Yahei;
cursor:pointer;
color:#333;
background:lightblue;
}
.alert_windows span:hover{
color:#EEE;
background:red;
}
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
$(function(){
if($.cookie("isClose") != 'yes'){
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 span").click(function(){
$(this).parent().fadeOut(500);
//以天為單位
//$.cookie("isClose",'yes',{ expires:1/8640});//測試十秒
$.cookie("isClose",'yes',{ expires:1});//一天
});
}
});
</script>
</head>
<body>
<p class="alert_windows">
<span>X</span>
</p>
</body>
</html>
版權聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉載請注明: 信息彈窗提示一天只彈出一次js代碼