为 JQuery UI 模态对话框设置 Cookie

发布于 2024-11-05 07:18:24 字数 1044 浏览 0 评论 0原文

当登录我们的网上银行产品以显示消息时,我们有一个 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>

IMPORTANT MESSAGE FOR ATM/DEBIT CARD HOLDERS

Federal Regulations recently changed, which means we are required to get your permission to consider paying overdrafts on your everyday debit transactions.

Please click here to find out important information regarding overdraft charges and debit card transactions.

We have a JQuery UI Modal Dialog when signing into our internet banking product to display a message. This pops up every single time. Now we want to make this cookie-based so a user only sees this box once until their cookies are cleared. How can I achieve this?

<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>

IMPORTANT MESSAGE FOR ATM/DEBIT CARD HOLDERS

Federal Regulations recently changed, which means we are required to get your permission to consider paying overdrafts on your everyday debit transactions.

Please click here to find out important information regarding overdraft charges and debit card transactions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盛装女皇 2024-11-12 07:18:24

最简单的是,您可以使用 jQuery Cookie 插件 创建一个 cookie 来存储他们是否看到它:

//Set a cookie value
$.cookie('seen', 'yes');

//get the value
var seen = $.cookie('seen');
if(seen == null) { /*have not seen, show modal*/ }

//delete cookie
$.cookie('seen', null);

Most simply you can create a cookie to store whether they have seen it or not using the jQuery Cookie Plugin:

//Set a cookie value
$.cookie('seen', 'yes');

//get the value
var seen = $.cookie('seen');
if(seen == null) { /*have not seen, show modal*/ }

//delete cookie
$.cookie('seen', null);
捎一片雪花 2024-11-12 07:18:24

当点击关闭按钮时,cookie将被存储
as( Cookie 名称 = subscribe_popup_status ) 值( 显示 )

$.cookie("cookie_name", "cookie_value");

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

});

When click the close button , cookie will stored
as( Cookie name = subscribe_popup_status ) value( shown )

$.cookie("cookie_name", "cookie_value");

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

});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文