fancybox

Hide fancybox 5 window from iframe


How can I close fancybox iframe window in version 5? (without any click) I need it after form submit, when task is finished.


Fancybox.bind("[data-fancybox='iframe1']", {
    defaultType:"iframe",
    preload:false,
    },
});


Solution

  • You can close Fancybox anywhere from the code using close static method:

    Fancybox.close();
    

    But, if you want to close Fancybox from within the iframe page, you simply have to access Fancybox from the parent page:

    window.parent.Fancybox.close();
    

    Demo - https://codesandbox.io/p/devbox/fancybox-iframe-qr4mx8