JS cookies undefined?
JS cookies undefined?
我正试图在网站上初次加载后使用JS cookie来关闭启动屏幕。但是,即使我设置了值,JS cookie也会不断返回undefined。基本上,cookie似乎没有保存值,所以启动屏幕一直显示。
$(document).ready(function() {
if (typeof Cookies.get('seen_splash') !== 'undefined') {
$(".splash").css("visibility", "visible");
console.log("splash visible");
$(".wrapper").css({"opacity":"0"});
/*$(".splash-arrow").click(function()
{
$(".splash").slideUp("800", function() {
$(".wrapper").delay(100).animate({"opacity":"1.0"},800);
Cookies.set('seen_splash', 'true', { expires: 1 });
console.log("cookies set to " + Cookies.get('seen_splash'));
});
});*/
}
// Set the cookie for 365 days.
$(".splash-arrow").on("click", function() {
$(".splash").slideUp("800", function() {
$(".wrapper").delay(100).animate({"opacity":"1.0"},800);
});
Cookies.set('seen_splash', 'true', { expires: 1 });
console.log("cookies set to " + Cookies.get('seen_splash'));
});
});
我认为您的逻辑中有一个错误。
单击启动箭头时,将seen_splash
的cookie设置为true
。
下一次,它会检查seen_splash
cookie是否未定义。它之前被设置为true
,这是未定义的,所以它再次显示飞溅。
您要检查的是seen_splash
cookie是否未定义,如果不是true
。
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- /undefined在我的404错误日志中多次出现
- RequireJS向模块传递配置总是返回undefined
- JSON数组数据返回Undefined
- 为什么会出现错误,“UncaughtTypeError:undefined不是函数”
- Array.lenght = undefined
- mongoose.connect undefined不是一个函数
- JavaScript”;.方法“;返回undefined
- Uncaught TypeError:undefined不是函数-ember js
- Jquery - table.row(tr) is undefined
- jQuery可以't获取data-*属性值,返回undefined
- angularjs中$cookiestore和$cookies之间的差异
- noty.js is returning undefined
- 将对象的列表c#传递给javascript:undefined变量时出错
- $routeParams is undefined
- 试图打印/调用/或提醒数组中的对象:Getting Undefined
- jQuery Mobile Undefined不是一个函数
- Angular - $cookies is undefined
- JS cookies undefined?
- AngularJS $cookies.get()总是返回undefined