Skip to main content

MailChimp Header iFrame Fix

Put the script after MailChimp scripts in the header. It will give a title to the two known iframes made by MailChimp's scripts. If you get a new iframe that isn't in here already, send it to Tom and he will get it accounted for in this script.

<script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function() {
        let checkCount = 0;
        const intervalId = setInterval(function() {
            const bannerIframe = document.querySelector('iframe[data-dojo-attach-point="iframeBannerContainer"]');
            const modalIframe = document.querySelector('iframe[data-dojo-attach-point="iframeModalContainer"]');
            if (bannerIframe || modalIframe || checkCount > 20) {
                clearInterval(intervalId);
                if (bannerIframe) {
                    bannerIframe.title = "mailchimp_iframe_banner";
                }
                if (modalIframe) {
                    modalIframe.title = "mailchimp_iframe_modal";
                }
            }
            checkCount++;
        }, 500);
    });
</script>