this SO 帖子中有更多答案。不幸的是,我找不到“真正的”解决方案,但其他人正在替换页面覆盖 CSS (#fancybox-overlay) 以包含微调器。然后,当 iframe 页面最终加载时,它被放置在微调器上。
编辑:
我放弃了使用 fancybox 来处理加载图像,并认为我会分享我的解决方案。我在页面中添加了我自己的绝对定位加载gif,在调用 fancybox 之前显示它,我可以使用 JQuery 捕获 iframe 加载事件以隐藏微调器,如下所示:
$( "#progressIcon" ).show();
$.fancybox.open( { type: "iframe", minWidth: 990, minHeight: 690, href: URL, title: "Basket" } );
$( "iframe" ).load( function ()
{
$( "#progressIcon" ).hide();
} );
如果您不像我一样手动调用fancybox,我假设您可以通过点击事件轻松附加此代码,即:
$('.fancybox').fancybox();
$('.fancybox').click( /* ... */ );
我还注意到,在播放 fancybox (v2.0.6) 源代码时,如果 autoSize 与 iFrame 一起使用,fancybox 似乎使用加载事件来显示/隐藏加载动画,尽管我没有测试过理论。
if (type === 'iframe' && current.autoSize) {
F.showLoading();
F._setDimension();
F.inner.css('overflow', current.scrolling);
content.bind({
onCancel : function() {
$(this).unbind();
F._afterZoomOut();
},
load : function() {
F.hideLoading();
try {
if (this.contentWindow.document.location) {
F.current.height = $(this).contents().find('body').height();
}
} catch (e) {
F.current.autoSize = false;
}
F[ F.isOpen ? '_afterZoomIn' : '_beforeShow']();
}
}).appendTo(F.inner);
} else {
F.inner.append(content);
F._beforeShow();
}