[英]How to set Cookie on Fancybox Close Button
我有下面的脚本可以工作,但是它会在加载时激活cookie。 如何仅在单击关闭按钮时激活cookie? 在“ OnLoad.html”页面上,我有一个关闭按钮和一个链接按钮。 我只希望单击关闭按钮时加载cookie。
我确实尝试了题为“在单击fancybox关闭按钮时设置cookie”的问题中的建议,但它根本没有起作用。
谢谢。
$(function() {
if ($.cookie('test')) {
}
else {
// set cookie to expire in x days
$.cookie('test', 'true', { expires: 50 * 365 });
$.fancybox( {
href : 'example.com/OnLoad.html',
type: 'ajax',
helpers: {
overlay : null
},
keys : {
close : null
},
closeBtn : false,
});
}
});
jQuery的
$("<YOUR-SELECTOR>").fancybox({
onClosed: function() {
$.cookie('test', 'true', { expires: 50*365});
})
});
然后在session.php上创建cookie
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.