Search code examples
javascriptjqueryhtmlfancyboxfancybox-2

Fancybox popup close button not showing


any idea why the close button is not appearing in my newsletter popup box?

Many thanks

  <script type="text/javascript">
function openFancybox() {
    setTimeout(function () {
        $.fancybox('#newsletterpopup', {
            modal: true, // this prevents fancybox to close unless close unless ".non-merci" is clicked
            showCloseButton: true,
            helpers: {
                overlay: {
                    css: {
                        'background': 'rgba(58, 42, 45, 0.3)'
                    }
                }
            },
            afterShow: function () {
                // enables a way to close fancybox
                $(".non-merci").on("click", function () {
                    $.fancybox.close()
                });
            }
        });
    }, 1000);
};
$(document).ready(function () {
    var visited = $.cookie('visited');
    if (visited == 'yes') {
        return false;
    } else {
        openFancybox();
    }
    $.cookie('visited', 'yes', {
        expires: 0.0001
    });
});
</script>

Solution

  • When you set

    modal: true
    

    close button will NEVER show up, regardless closeBtn is set to true.

    You either remove the modal option (which default is false) or set it to false

    Notice that showCloseButton is an option for fancybox v1.3.x.