Fancybox-使用iframe内容更新fancybox的大小吗? [英] Fancybox - Updating size of fancybox with Iframe content?
问题描述
在我的网站上,我打开了一个包含IFRAME内容的幻想框.单击其中的链接时,是否可以更新fancybox的大小?
On my site I open up a fancybox containing IFRAME content. Is it possible to update the size of the fancybox when a link is clicked within it?
例如,我最初将其设置为535px宽度,当单击特定链接时,我希望将fancybox调整为900px宽度.
For example, I have it set to 535px width initially, when a specific link is clicked I'd like the fancybox to resize to 900px width.
有什么想法可以实现吗?
Any idea how I can achieve this?
谢谢!
推荐答案
我认为我也遇到了同样的问题,在我的情况下,fancybox.resize无效,但这对我有用:
I think I just have the same problem and in my case, fancybox.resize didn't work but this worked for me:
$("#lightbox").fancybox({
'hideOnContentClick' : true,
'width' : 500,
'type' : 'iframe',
'padding' : 35,
'onComplete' : function() {
$('#fancybox-frame').load(function() { // wait for frame to load and then gets it's height
$('#fancybox-content').height($(this).contents().find('body').height()+30);
});
}
});
向伊恩·霍尔(Ian Hoar)致谢,以便在此处发布: http://www.ianhoar.com/2011/08/25/jquery-and-fancybox-how-to-automatically-set-the-height-of-iframe-lightbox/
Credit to Ian Hoar to posting that here: http://www.ianhoar.com/2011/08/25/jquery-and-fancybox-how-to-automatically-set-the-height-of-an-iframe-lightbox/
这篇关于Fancybox-使用iframe内容更新fancybox的大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!