Fancybox - Updating size of fancybox with Iframe content?

后端 未结 4 924
难免孤独
难免孤独 2020-12-17 02:02

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?

For example, I have it

4条回答
  •  长情又很酷
    2020-12-17 02:58

    $('a', $('#youriframeID').contentDocument).bind('click', function() {
        preventDefault();
        $('#yourIframeID').attr('src', $(this).attr('href'));
        $('#yourIframeID').load(function() {
            $.fancybox.resize;
        });
    });
    

    If an 'a' is clicked within your iframe, the default events will be blocked. Instead, we change the src of your iframe. When it's loaded, #.fancybox.resize will automatically resize the fancybox in respect to the content. This is an idea, so the code will probably not yet work. Just to help you get on the right track.

提交回复
热议问题