我正在尝试使用SimpleModal作为电子邮件免责声明的确认,即点击电子邮件地址弹出模式,同意免责声明的用户可以使用mailto:方法发送电子邮件,拒绝的用户不会获得弹出。
这是我到目前为止所做的,除了确认时没有邮件客户端弹出窗口,它几乎可以正常工作:
<a href="mailto:user@domain.com" class="confirm">user@domain.com</a>
<div id='confirm'>
<div class='header'><span>Confirm</span></div>
<div class='message'></div>
<div class='buttons'>
<div class='no simplemodal-close'>Cancel</div>
<div class='yes'>Confirm</div>
</div>
</div>
和javascript:
jQuery(function ($) {
$('a.confirm').click(function (e) {
e.preventDefault();
msg = 'this is the copy of the confirmation dialog I want to pop up, it goes on and on and on';
// example of calling the confirm function
// you must use a callback function to perform the "yes" action
confirm(msg, function () {
window.location.href = hrefval;
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
position: ["20%",],
minWidth: '660px',
minHeight: '400px',
overlayId: 'confirm-overlay',
containerId: 'confirm-container',
onShow: function (dialog) {
var modal = this;
$('.message', dialog.data[0]).append(message);
// if the user clicks "yes"
$('.yes', dialog.data[0]).click(function () {
// call the callback
if ($.isFunction(callback)) {
callback.apply();
}
// close the dialog
modal.close(); // or $.modal.close();
});
}
});
}
答案 0 :(得分:0)
想出来,我只需要明确地获取href值。
jQuery(function ($) {
$('a.confirm').click(function (e) {
e.preventDefault();
href = $(this).attr('href');
msg = 'this is the copy of the confirmation dialog I want to pop up, it goes on and on and on';
// example of calling the confirm function
// you must use a callback function to perform the "yes" action
confirm(msg, function () {
window.location.href = href;
});
});
});