Fancybox - 使用Iframe内容更新fancybox的大小?

Pro*_*cop 6 jquery fancybox

在我的网站上,我打开了一个包含IFRAME内容的fancybox.是否可以在其中单击链接时更新fancybox的大小?

例如,我最初将其设置为535px宽度,当点击特定链接时,我希望将fancybox调整为900px宽度.

知道我怎么能做到这一点?

谢谢!

why*_*d.i 18

我想我有同样的问题,在我的情况下,fancybox.resize没有用,但这对我有用:

$("#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);
    });
  }
});
Run Code Online (Sandbox Code Playgroud)

感谢Ian Hoar在此发布:http: //www.ianhoar.com/2011/08/25/jquery-and-fancybox-how-to-automatically-set-the-height-of-an-iframe-lightbox /

  • Fancybox v2-version: ` $('.fancybox').fancybox({ type: 'iframe', afterShow: function() { $('.fancybox-iframe').load(function() { $('.fancybox -inner').height($(this).contents().find('body').height()+30); }); } }); ` (10认同)