即时通讯使用以下代码作为javascript中的确认框的替代品。如何让fancybox通过href onclick显示“yes/no confirm box”?
function fancyAlert(msg) {
jQuery.fancybox({
'modal' : true,
'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input style=\"margin:3px;padding:0px;\" type=\"button\" onclick=\"jQuery.fancybox.close();\" value=\"Ok\"></div></div>" }); }
function fancyConfirm(msg, callback) {
var ret;
jQuery.fancybox({
'modal' : true,
'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input id=\"fancyConfirm_cancel\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Cancel\"><input id=\"fancyConfirm_ok\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Ok\"></div></div>",
onComplete : function() {
jQuery("#fancyConfirm_cancel").click(function() {
ret = false;
jQuery.fancybox.close();
})
jQuery("#fancyConfirm_ok").click(function() {
ret = true;
jQuery.fancybox.close();
})
},
onClosed : function() {
if (typeof callback == 'function'){ callback.call(this, ret); };
}
});
}
function fancyConfirm_text() {
fancyConfirm("Ceci est un test", function(ret) {
alert(ret)
})
}
使用这样的超级链接
和IM:
<a href="http://www.example.com/" onclick="fancyConfirm("Are you sure you want to delete?");">Test</a>
IM卡,它只是不会显示任何内容?我认为它有事情做与fancyConfirm所需的回调变量,但即时通讯无法确定是什么这意味着它是如何应用的。
感谢您的帮助。
对不起,这是我的错误,我已经有单引号,但它仍然不起作用? ,还有其他建议吗? – PHPNewEE 2011-04-19 14:02:13