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")
})
})