如何在Fancybox 2中动态调整iframe大小?

5

我正在使用 Fancybox 2.0. 我在一个 iframe 中打开内容。当 iframe 中的内容改变时,如何动态调整弹出窗口的大小?

我谷歌了几个小时,但所有的链接都是针对旧版本(1.3)或死链。

感谢您的帮助!

3个回答

0
您可以使用autoSize选项将iframe的宽度和高度调整为内容的宽度和高度。 如果autoSize为true,则将autoHeight和autoWidth都设置为true。这意味着对于“inline”,“ajax”和“html”类型的内容,宽度和高度是自动确定的。
$.fancybox.open({
padding : 0,
href:'http://www.gamespot.com',
type: 'iframe',
autoSize: true
});

0
我使用了"before show"选项来调整它的大小。
 beforeShow: function(){
    this.width = $('.fancybox-iframe').contents().find('html').width();
    this.height = $('.fancybox-iframe').contents().find('html').height();
 }

如果要在框架内运行此程序,您需要从子页面触发parent.$.fancybox.update(),以便调整大小。


-1

这应该可以做到。

$.fancybox({
  width:600,
  height:300,
  autoResize:false
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接