帮助设置Cookie的JQuery UI模态对话框 [英] Help With Setting Cookie for a JQuery UI Modal Dialog
问题描述
我们拥有一个网上银行网站,登录后,我创建了一个模态对话框显示。
We host an internet banking site and upon logging in, I created a modal dialog box to display.
我们现在想采取一个基于cookie的方法,看过一次。我完全失去了如何做到这一点。我有代码包括,如果有人可以帮助,我真的很感激。我需要准确的如何编码这个。我不是很熟练的html / javascript - 我能够实现这个相当幸运的老实说。但现在我不能得到cookie部分工作!感谢任何能够帮助我的人。
We now want to take a cookie based approach so it's only seen once. I'm completely lost on how to do this. I have the code included and if someone could help, I'd really appreciate it. I'd need exactly how to code this. I'm not very skilled in html/javascript - I was able to implement this quite luckily honestly. But now I'm unable to get the cookie portion working! Thanks to anyone who is able to help me out.
<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>
<div class="optinpopup">
<div id="dialog-modal" title="Alert">
<br><b>IMPORTANT MESSAGE FOR ATM/DEBIT CARD HOLDERS</b>
<br><br>
Federal Regulations recently changed, which means we are required to get your permission to consider paying overdrafts on your everyday debit transactions.
<br><br>
Please <a href="www.websitehere.com" style="text-decoration: none; " target="_blank"><b>click here</b></a> to find out important information regarding overdraft charges and debit card transactions.
<br></div></div>
推荐答案
获取 jQuery Cookie插件,并更改您的代码,如下所示:
Grab the jQuery cookie plugin and change your code like so:
$(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
$( "#dialog:ui-dialog" ).dialog( "destroy" );
if ($.cookie('showDialog') == undefined || $.cookie('showDialog') == null || $.cookie('showDialog') != 'false') {
$( "#dialog-modal" ).dialog({
height: 475,
width: 550,
position: 'top',
modal: true,
buttons:{ "Close": function() { $(this).dialog("close"); $.cookie('showDialog', 'false', { expires: 3650 }); } },
draggable: false,
resizable: false
});
}
});
这篇关于帮助设置Cookie的JQuery UI模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!