2011-03-10 82 views
0

我有一個腳本我正在使用加載窗口,設置cookie,但窗口不會再次出現,如果用戶點擊「不,謝謝」,但我想如果他們也點擊「進行調查」,窗口不會出現。我嘗試在這裏添加第二個ID $('#modal_close, #modal_exit').live('click', function(e) {,但它不起作用。而不是去調查的鏈接,它進入模式從發射的頁面。任何線索和/或幫助?jQuery:Modal窗口加載fancybox + cookies

$(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() 
    }); 
}  

})我要尋找節目的價值;

回答

0

所以我在這裏發帖後就想通了......是不是總是這樣?安美居,有人可能希望做我說同樣的事情如下:

$('#modal_exit').live('click', function(e) { 
    $.cookie("cookieName", "true", { path: '/', expires: 7 });  
    $.fancybox.close() 
}); 

我刪除e.preventDefault();因爲如果被觸發點擊錨不會採取瀏覽器到一個新的URL。刪除它可以檢查cookie,並讓我的鏈接將我帶到我想去的地方。