调整 jQuery Fancybox' iframe高度根据里面内容的变化动态变化
我正在使用 jQuery Fancybox 在模式窗口中显示表单。我使用以下代码:
$("a.iframe").fancybox({
'padding': 0,
'width': 650,
'showCloseButton': false,
'hideOnContentClick': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'onComplete': function () {
$('#fancybox-frame').load(function () {
$('#fancybox-content').height($(this).contents().find('body').height() + 20);
});
}
});
通过附加的 onComplete 函数,我可以根据内部内容的高度调整 iframe 的高度。
但是,我在 iframe 中使用 jQuery 的 .hide() 隐藏了一些元素。每当我想要 .show() 这些元素时,iframe 本身不会随着现在可见元素的额外高度而调整大小。
我怎样才能做到这一点?谢谢!
I'm using jQuery Fancybox to display forms in a modal window. I'm using the following code:
$("a.iframe").fancybox({
'padding': 0,
'width': 650,
'showCloseButton': false,
'hideOnContentClick': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'onComplete': function () {
$('#fancybox-frame').load(function () {
$('#fancybox-content').height($(this).contents().find('body').height() + 20);
});
}
});
With the additional onComplete function, I'm able to adjust the height of the iframe accordingly to the height of the contents inside.
However, I've hidden a few elements with jQuery's .hide() inside the iframe. Whenever I want to .show() these elements, the iframe itself doesn't resize along with the extra height of the now visible elements.
How can I accomplish this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将下面的函数放到页面
后,触发这个函数到你的showHide函数中。例如;
Put the following function to the page
After, trigger this function to your showHide function. For example;