Javascript jQuery:使用fancybox+;饼干
我有一个脚本,我正在使用它加载窗口,设置cookie,但是如果用户单击“不,谢谢”,窗口不会再次出现,但是如果他们也单击“接受调查”,我希望窗口不会出现。我尝试在这里添加第二个IDJavascript jQuery:使用fancybox+;饼干,javascript,jquery,cookies,modal-dialog,Javascript,Jquery,Cookies,Modal Dialog,我有一个脚本,我正在使用它加载窗口,设置cookie,但是如果用户单击“不,谢谢”,窗口不会再次出现,但是如果他们也单击“接受调查”,我希望窗口不会出现。我尝试在这里添加第二个ID$(“#modal_close,#modal_exit”).live('click',function(e){),但它不起作用。它没有转到调查链接,而是转到modal从中触发的页面。有任何线索和/或帮助吗 $(document).ready(function(){ //模式框如果请求的cookie没有我要查找的值,则
$(“#modal_close,#modal_exit”).live('click',function(e){
),但它不起作用。它没有转到调查链接,而是转到modal从中触发的页面。有任何线索和/或帮助吗
$(document).ready(function(){
//模式框如果请求的cookie没有我要查找的值,则显示模式框
if($.cookie("cookieName") != 'true')
{
var _message_to_show = 'Window Content Goes Here';
// on page load show the modal box
// more info about the options you can find on the fancybox site
$.fancybox(
_message_to_show,
{
'width' : 550,
'height' : 275,
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'centerOnScroll' : 'true',
'overlayOpacity' : 0.8,
'overlayColor' : '#000',
'modal' : 'true',
'padding' : 5
}
);
// in the message is a link with the id "modal_close"
// when you click on that link the modal will close and the cookie is set to "true"
// path "/" means it's active for the entire root site.. if you set it to "/admin" will be active on the "admin" folder
// expires in 7 days
// "modal" is the name i gave the cookie, you can name it anything you want
$('#modal_close').live('click', function(e) {
e.preventDefault();
$.cookie("cookieName", "true", { path: '/', expires: 7 });
$.fancybox.close()
});
}
})) 所以我在这里发布后就发现了。。。不是一直都是这样吗?Anyhoo,对于希望做同样事情的人,我添加了以下内容:
$('#modal_exit').live('click', function(e) {
$.cookie("cookieName", "true", { path: '/', expires: 7 });
$.fancybox.close()
});
我删除了e.preventDefault()代码>因为单击的锚定不会将浏览器带到新的URL(如果触发)。删除它可以检查cookie,并让我的链接带我去我想去的地方