为JQuery UI模式对话框设置Cookie

时间:2011-05-05 15:39:47

标签: jquery user-interface cookies modal-dialog

登录我们的网上银行产品以显示消息时,我们有一个JQuery UI模式对话框。每次弹出这个。现在我们想要使这个基于cookie,因此用户只能看到此框一次,直到他们的cookie被清除。我怎样才能做到这一点?

<body onLoad="loadPage();" onUnload="unloadPage();">
<script>

$(function() {
    // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
    //$( "#dialog:ui-dialog" ).dialog( "destroy" );


    $( "#dialog-modal" ).dialog({
        height: 475,
        width: 550,
        position: 'top',
        modal: true,
        buttons:{ "Close": function() { $(this).dialog("close"); } },
        draggable: false,
        resizable: false
    });

});


</script>
    
ATM /借记卡持有人的重要信息

        联邦法规最近发生了变化,这意味着我们必须获得您的许可才能考虑支付日常借记交易的透支费用。         

        请点击此处查找有关透支费用和借记卡交易的重要信息。         

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

  

单击关闭按钮时,将存储cookie   as(Cookie name = subscribe_popup_status)值(显示)

$ .cookie(&#34; cookie_name&#34;,&#34; cookie_value&#34;);

$( '.home_page_popup' ).dialog({ 
   autoOpen: false,
   closeText: "",
   modal: true,
   resizable: false,
   icon: "ui-icon-heart",
   classes: {
       "ui-dialog": "home_page_popup_dialog"
   },
   width: pop_up_width
});

$(".home_page_popup").on("click",".popup_close",function() {

    if ($.cookie('subscribe_popup_status') == null) {
       $.cookie('subscribe_popup_status', 'shown',{ expires: popup_duration });
    }

    $( '.home_page_popup' ).dialog('close');

});
相关问题