只有点击关闭按钮才会关闭,并记录cookie,刷新不会记录,
本文转载 :https://www.xp.cn/b.php/63896.html
<script>
window.onload = function() {
if (getCookie("footad") == 0) {
document.getElementById("xppen_fixed").style.display = "none";
} else {
document.getElementById("xppen_fixed").style.display = "block";
}
}
//关闭底部广告
function closeFootAd() {
document.getElementById("xppen_fixed").style.display = "none";
setCookie("footad", "0");
}
//设置cookie
function setCookie(name, value) {
var exp = new Date();
exp.setTime(exp.getTime() + 20* 1000); //有效期1小时
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
//取cookies函数
function getCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return unescape(arr[2]);
return null;
}
</script>