html:
<div class=”pop-download-warp”>
<div class="pop-download">
<h3>e手机App推出新功能</h3>
<p>邻里互撩,让沟通无障碍!</p>
<p class="font-bottom">群组形式,让群聊嗨起来!</p>
<a href="/app/download">前去eApp</a>
<div class="close-btn" id="pop-download-btn"></div>
</div>
</div>
js:
$(function(){
function setCookie (name, value) {
var curDate = new Date();
//当前时候戳
var curTamp = curDate.getTime();
//当前日期
var curDay = curDate.toLocaleDateString();
var brow = $.browser;
var curWeeHours = 0;
if (window.navigator.userAgent.indexOf("Chrome") !== -1) {
//当日凌晨的时候戳,减去一毫秒是为了防备后续获得的时候不会到达00:00:00的状况
curWeeHours = new Date(curDay).getTime() + (8 * 60 * 60 * 1000) - 1;
} else {
curWeeHours = new Date(curDay).getTime() - 1;
}
//当日已过去的时候(毫秒)
var passedTamp = curTamp - curWeeHours;
//当日剩余时候
var leftTamp = 24 * 60 * 60 * 1000 - passedTamp;
var leftTime = new Date();
leftTime.setTime(leftTamp + curTamp);
//建立cookie
document.cookie = name + "=" + value + ";expires=" + leftTime.toGMTString() + ";path=/";
}
function getCookie (name) {
//name 为想要取到的键值的键名
var reg = /\s/g;
var result = document.cookie.replace(reg, "");
var resultArr = result.split(";");
for (var i = 0; i < resultArr.length; i++) {
var nameArr = resultArr[i].split("=");
if (nameArr[0] == name) {
return nameArr[1];
}
}
}
if(getCookie('display')=="hidden"){
$('.pop-download-warp').css('display',"none")
}else{
setCookie('display',"hidden")
$('.pop-download-warp').css('display',"flex")
}
$("#pop-download-btn").on("click",function(){
$('.pop-download-warp').css('display',"none")
})
})