Est*_*her 3 javascript cookies jquery
我有一个带有cookie的弹出窗口,它会在一天(24小时)内到期,我希望这个cookie每天午夜到期(所以弹出窗口显示你每天第一次进入网络).我不是程序员,所以,请问有人可以告诉我在代码中需要更改的内容吗?我已经阅读了一些问题的解决方案,但我不知道如何实现它.
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
if ($.cookie("anewsletter") != 1) {
//centering with css
centerPopup();
//load popup
loadPopup();
}
//CLOSING POPUP
//Click the x event!
$("#popupContactClose").click(function(){
disablePopup();
$.cookie("anewsletter", "1", { expires: 1 });
});
//Click the bacground!
$("#backgroundPopup").click(function(){
disablePopup();
$.cookie("anewsletter", "1", { expires: 1 });
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
$.cookie("anewsletter", "1", { expires: 1 });
}
});
});
Run Code Online (Sandbox Code Playgroud)
非常感谢你!
小智 7
$.cookie可以将日期作为expires值,因此您可以使用以下内容
var midnight = new Date();
midnight.setHours(23,59,59,0);
$.cookie('anewsletter', '1', { expires: midnight });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2915 次 |
| 最近记录: |