-
05-07-2019 - |
题
我想要实现如下:
- 在主页上载,显示的模式中
- 在模式中,显示有形成一个单一的强制性框
- 在检查框,打提交和关闭模式中,继续主页
- 记住这个框中打勾偏好用一个饼干
- 在一个用户回到主页,如果它们已经检查的框, 该模式中不会显示
我已经找到这个:
http://dev.iceburg.net/jquery/jqModal
在那我可以得到的模式框显示,在页面装载,但是我不会工作如何获得的形式,使该框强制性和紧密的箱子。我也不知道从哪里开始设定时的cookie。
任何指针,将不胜感激。
感谢
编辑:包括代码:
Index.html -来显示模式框页上载
$().ready(function() {
$('#ex2').jqm({modal: 'true', ajax: '2.html', trigger: 'a.ex2trigger' });
setTimeout($('#ex2').jqmShow(),2000);
});
2.html -模式中的内容载入通过阿贾克斯
function validate(frm) {
if (frm.checkbox.checked==false)
{
alert("Please agree to our Terms and Conditions.");
return false;
}
}
<form action="" method="POST" onSubmit="return validate(form);" name="form">
<input type="checkbox" name="checkbox" id="checkbox" value="1"> I hereby agree to all Terms and Conditions</a>
<input type="submit" value="Submit">
</form>
解决方案
载s cookie插件允许设置读/cookies: http://plugins.jquery.com/project/cookie 然后..这样的事情如下。未经测试,但你的想法
index.html:
$().ready(function() {
if (!$.cookie('agreed_to_terms'))
{
$('#ex2').jqm({modal: 'true', ajax: '2.html', trigger: 'a.ex2trigger' });
$('#ex2').jqmShow();
}
});
2.html:
$().ready(function()
{
$('#agreeFrm').submit(function(e)
{
e.preventDefault();
if ($(this).find('input[name=checkbox]').is(':checked'))
{
$.cookie('agreed_to_terms', '1', { path: '/', expires: 999999 });
$('#ex2').jqmHide();
}
});
});
<form id="agreeFrm" action="" method="POST" name="form">
<input type="checkbox" name="checkbox" id="checkbox" value="1"> I hereby agree to all Terms and Conditions</a>
<input type="submit" value="Submit">
</form>
其他提示
我用一个JQuery插件不久前称为SimpleModal
我印象非常深刻,它是多么容易.在模式我有多种选择框并进行价值观的框回页的模式是在后提交按钮被击中。
所有的信息和演示是在 SimpleModal主页
它的工作,终于来了!我是缺少回调当cookie存在和这些抽动"围绕价值的cookie。这里是怎么样的。请让我知道如果有一些明显的错误。(多谢您的支持)
function confirm(msg,callback) {
$('#confirm')
.jqmShow()
.find('p.jqmConfirmMsg')
.html(msg)
.end()
.find(':submit:visible')
.click(function(){
if(this.value == 'Proceed'){
$.cookie("agreed_to_terms", '1', { expires : 1, path: '/' }); //set cookie, expires in 365 days
(typeof callback == 'string') ?
window.location.href = callback :
callback();
}
$('#confirm').jqmHide();
});
}
$().ready(function() {
$('#confirm').jqm({overlay: 88, modal: 'true', trigger: false});
// trigger a confirm whenever links of class alert are pressed.
$('a.confirm').click(function() {
if ($.cookie('agreed_to_terms') == '1'){window.location.href = callback =
callback()
//they already have cookie set
}else{
confirm('About to visit: '+this.href+' !',this.href);
}
return false;
});
});// JavaScript Document
不隶属于 StackOverflow