Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在fancybox的cookie设置中更改过期时间?_Jquery_Cookies_Fancybox_Jquery Cookie - Fatal编程技术网

Jquery 如何在fancybox的cookie设置中更改过期时间?

Jquery 如何在fancybox的cookie设置中更改过期时间?,jquery,cookies,fancybox,jquery-cookie,Jquery,Cookies,Fancybox,Jquery Cookie,JS: 它起作用了。我想把过期时间改为3天。我怎样才能修好它?像这样试试 $(document).ready(function() { var check_cookie = $.cookie('the_cookie'); if(check_cookie == null){ $.cookie('the_cookie', 'the_value', { expires: 30 * 60 * 1000 }); $("#hidden_link").fancybox().trigge

JS:

它起作用了。我想把过期时间改为3天。我怎样才能修好它?

像这样试试

$(document).ready(function() {
  var check_cookie = $.cookie('the_cookie');
  if(check_cookie == null){
    $.cookie('the_cookie', 'the_value', { expires: 30 * 60 * 1000 });
    $("#hidden_link").fancybox().trigger('click');
  }   
});

试试这个,你可以通过一个日期

$(document).ready(function() {
  var check_cookie = $.cookie('the_cookie');
  if(check_cookie == null){
    $.cookie('the_cookie', 'the_value', { expires: time()+3600*24*3 });
    $("#hidden_link").fancybox().trigger('click');
  }   
});
或者将日期作为参数发送

var date = new Date();
date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
$.cookie("the_cookie", "the_value", { expires: date });
输出

如果在浏览器控制台中运行该函数,jquery cookie已经作为源出现,则在这两种情况下都会打印

_cookie=_值;expires=2013年12月30日星期一08:28:36 GMT


当前时间是2013年12月27日星期一08:28:36 GMT

这是一个简单的数学问题吗?您使用的是哪个版本?在wiki页面中,只需指定如下内容:$.cookie'the_cookie','the_value',{expires:3};三天。
$.cookie('the_cookie', 'the_value', { expires: 3 });