在我的fancybox onpage加载上设置一个jquery cookie [英] Set a jquery cookie on my fancybox onpage load
本文介绍了在我的fancybox onpage加载上设置一个jquery cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是用来加载fancybox页面加载。但是,我希望这个可以出现在新的访问者或3天前访问过该页面的用户。
this is what is used to load fancybox on page load. However, I want this to be appeared on new visitors or people who visited the page 3 days ago.
我猜用一个jQuery cookie,但我不知道如何。
I guess with a jQuery cookie but I don't know how.
jQuery(document).ready(function() {
$.fancybox(
'<h2>Hi!</h2><p>Lorem ipsum dolor</p>',
{
'autoDimensions' : false,
'width' : 350,
'height' : 'auto',
'transitionIn' : 'none',
'transitionOut' : 'none'
}
);
});
推荐答案
在< head> ;
add < script src =jquery.cookie.js>< / script>
,然后:
$(function() {
if ($.cookie('mycookie')) {
// it hasn't been three days yet
} else {
$.fancybox(
'<h2>Hi!</h2><p>Lorem ipsum dolor</p>',
{
'autoDimensions' : false,
'width' : 350,
'height' : 'auto',
'transitionIn' : 'none',
'transitionOut' : 'none'
}
);
}
});
// set cookie to expire in 3 days
$.cookie('mycookie', 'true', { expires: 3});
这使用 cookie 插件。
这篇关于在我的fancybox onpage加载上设置一个jquery cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文