Javascript fancybox未打开,不确定原因
我正在尝试用fancybox的最新版本2.3.4打开一个fancybox,下面的代码似乎不起作用,也没有抛出错误 我只是不明白为什么它不打开页面:Javascript fancybox未打开,不确定原因,javascript,jquery,fancybox,Javascript,Jquery,Fancybox,我正在尝试用fancybox的最新版本2.3.4打开一个fancybox,下面的代码似乎不起作用,也没有抛出错误 我只是不明白为什么它不打开页面: $(".openmails1").click(function() { var sender = $(this).attr('data-id'); var subject = $(this).attr('title'); var mailid = $(this).attr('re
$(".openmails1").click(function() {
var sender = $(this).attr('data-id');
var subject = $(this).attr('title');
var mailid = $(this).attr('rel');
$.fancybox.open({
href: '/account/compose.cfm?sender='+sender+'&subject='+subject+'&mailid='+mailid,
maxWidth : 600,
maxHeight : 900,
fitToView : true,
width : '70%',
height : '80%',
autoSize : true,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
scrolling : 'no'
});
});
我是这样称呼它的
<a data-fancybox-type="iframe" title="This is a Welcome Email" data-id="24" rel="myemail@domain.com" href="javascript:void(0);" class="openmails1">Inia Ornit</a>
它总是打开第一条记录,不管我是否打开最后一条记录,总是作为第一条记录,不知道为什么会这样发生
$(".openmails1").fancybox({
href: '/account/compose.cfm?sender='+$(".openmails1").attr('data-id')+'&subject='+$(".openmails1").attr('title')+'&mailid='+$(".openmails1").attr('rel')+'&frmaccount=1',
maxWidth : 600,
maxHeight : 900,
fitToView : true,
width : '70%',
height : '80%',
autoSize : true,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
scrolling : 'no'
});
$.fancybox.open([
{
href : 'http://fancyapps.com/fancybox/demo/1_b.jpg',
maxWidth : 600,
maxHeight : 900,
fitToView : true,
width : '70%',
height : '80%',
autoSize : true,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
scrolling : 'no'
}
], {
padding : 0
});
希望这有帮助
更新1
根据你的更新代码,我想你必须改成
$(".openmails1").click(function(e) {
e.preventDefault();
$(".openmails1").fancybox({
href: '/account/compose.cfm?sender='+$(this).attr('data-id')+'& subject='+$(this).attr('title')+'&mailid='+$(this).attr('rel')+'&frmaccount=1',
maxWidth : 600,
maxHeight : 900,
fitToView : true,
width : '70%',
height : '80%',
autoSize : true,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
scrolling : 'no'
});
});
您必须为单击的每个超链接创建一个奇特的框。请参阅运行示例
$.fancybox.open([
{
href : 'http://fancyapps.com/fancybox/demo/1_b.jpg',
maxWidth : 600,
maxHeight : 900,
fitToView : true,
width : '70%',
height : '80%',
autoSize : true,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
scrolling : 'no'
}
], {
padding : 0
});
希望这就是你想要的。我改变了你让我直接打电话的方式,但现在发生了一件奇怪的事情:我在问题中添加了一个更新。是的,它在我的系统或代码中不起作用,所以我直接打电话,它起了作用,谢谢