fancyBox3 trigger an iframe

2019-08-08 04:54发布

问题:

In a old fancyboxversion i open a iframe with this code

$.fancybox({
                'padding':  20,
                'width':    '650px',
                'type':     'iframe',
                'href':     '....php?anchor=' + xyz,
                'autoDimensions': true,
                'autoScale': true,
                'centerOnScroll': true,
                'scrolling'     : 'no',
                afterClose : function(){
                    location.reload();
                }
            }); 

in a new version is it not possible. Any ideas?

回答1:

Just take a look at docs/API. It would be like this:

$.fancybox.open({
    src : 'https://codepen.io/',
    type : 'iframe',
    opts : {
        iframe : {
            css : {
                width: '500px'
            },
            attr : {
                scrolling : 'no'
            }
        },
        afterClose : function() {
            alert('done!');
        }
    }
});

Demo - https://codepen.io/anon/pen/BmbmJX?editors=1010