I have an iframe that is made by Sendinblue that adds an email and a name to a subscriber list for emails about news and updates to the website. I try to add a script inside of script tags to a div inside of the iframe, and the script adds a cookie to my domain to make sure the subscription pop-up doesn't appear if the person has already subscribed. This is the script code that works and shows the iframe properly:
<script>
var loadSubscribe = document.getElementById("iframeSubContainer");
var subIframe = document.createElement("iframe");
subIframe.src = "https://5eb037e3.sibforms.com/serve/MUIEAJ939z1Bq2LxF5Zhl4FTxrbO_BRWpsH3pI1Oc3BlfERyduUrKn8MZGOp_SfE8ANeCph9Ho774Ez3WHnEGB8HA2SUKdqotNxM9BrRc56WQOdxp2sXCz4l9pinjkJOMDiRsG9uY4SAvobb3Gv2BoKx_iWdBOaxVmg7qlkzPx6pzha-j8NErMxJXTB85a0OqOs-bLG8_y-Fi-xx";
subIframe.width = "540";
subIframe.height = "755";
subIframe.frameBorder ="0";
subIframe.scrolling = "no";
subIframe.style["opacity"] = "1";
subIframe.style["display"] = "block";
subIframe.style["border"] = "none";
subIframe.style["background"] = "white";
subIframe.style["marginLeft"] = "auto";
subIframe.style["marginRight"] = "auto";
subIframe.style["maxWidth"] = "100%";
subIframe.setAttribute("id", "subIframe");
loadSubscribe.appendChild(subIframe)
</script>
and in the head tag i have:
<script src="http://code.jquery.com/jquery-latest.js"></script>
But, if I add
$('#subIframe').contents().find('#success-message').append('<script>document.cookie="CookieName=cookieData; expires=Thu, 01 Jan 2038 00:00:00 UTC; path=urlCookiePath/;"<\/script>');,
which adds the cookie script if a person subscribes and the success message is shown, and I put it right under
subIframe.setAttribute("id", "subIframe");,
the iframe does not appear at all. Am writing this wrong?
The link to the subscription page is here, so you can see the html source code