x 秒后向上滑动面板,单击关闭 - SET COOKIE
希望有人能指出我正确的方向。
我们正在努力改善邮件列表的订阅。当用户在 x 秒后访问我们的网站时,我希望有一个面板向上滑动,要求他们注册邮件列表。
如果他们单击任何按钮(注册、关闭、不再显示),我想设置一个 cookie,以便面板不会再次显示。
我已经掌握了向上/向下滑动,但我是 cookie 方面的新手,不知道如何设置它,因此当设置 cookie 时,滑动操作不会再次发生。
这是我的 jQuery...
// MAILING LIST SLIDER //
// set a delay of 3 seconds before mailing list panel appears
$("#mailingListPanelSlide").delay(3000).slideDown("slow");
// set triggers to close the mailing list panel & set cookie
$("a#closeButton, p.negativeActionFormButton").click(function(){
$("div#mailingListPanelSlide").slideUp("slow");
$.cookie("mailingListPanel", "dontshow");
});
// HELP!!!! if cookie is set to collapsed, then don't perform slide down/hide panel altogether?
var mailingListPanel = $.cookie("mailingListPanel");
if (mailingListPanel == "dontshow") {
$("div#mailingListPanelSlide").css("display","none");
};
//END MAILING LIST SLIDER //
hoping someone can point me in the right direction.
We're trying to improve subscriptions to our mailing list. When a user visits our site after x amount of seconds, i'd like a panel to slide up asking them to sign up to the mailing list.
If they click any of the buttons (sign up, close, dont show again) I want to set a cookie so the panel doesn't show again.
I've mastered the slide up/down BUT i'm a newbie at the cookie side of things and not sure how to set it so when the cookie is set, the slide action doesn't occur again.
Here's my jQuery...
// MAILING LIST SLIDER //
// set a delay of 3 seconds before mailing list panel appears
$("#mailingListPanelSlide").delay(3000).slideDown("slow");
// set triggers to close the mailing list panel & set cookie
$("a#closeButton, p.negativeActionFormButton").click(function(){
$("div#mailingListPanelSlide").slideUp("slow");
$.cookie("mailingListPanel", "dontshow");
});
// HELP!!!! if cookie is set to collapsed, then don't perform slide down/hide panel altogether?
var mailingListPanel = $.cookie("mailingListPanel");
if (mailingListPanel == "dontshow") {
$("div#mailingListPanelSlide").css("display","none");
};
//END MAILING LIST SLIDER //
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想使用 $.cookie 你必须有 jQuery cookie 插件
https://github.com/carhartl/jquery-cookie
You must have the jQuery cookie plugin if you want to use $.cookie
https://github.com/carhartl/jquery-cookie