When I add the javascript code bellow to my website, the form is not shown

  • Profile Image
    Nicholas
    Asked on July 20, 2015 at 08:20 AM

    when i paste the below code on my web page and save.

    window.handleIFrameMessage = function(e) {var args = e.data.split(":");var iframe = document.getElementById("JotFormIFrame");if (!iframe)return;switch (args[0]) {case "scrollIntoView":iframe.scrollIntoView();break;case "setHeight":iframe.style.height = args[1] + "px";break;case "collapseErrorPage":if (iframe.clientHeight > window.innerHeight) {iframe.style.height = window.innerHeight + "px";}break;case "reloadPage":window.location.reload();break;}};if (window.addEventListener) {window.addEventListener("message", handleIFrameMessage, false);} else if (window.attachEvent) {window.attachEvent("onmessage", handleIFrameMessage);}

    after i save, the below appear on my web page instead of the form, what im i doing wrong, pls help.

    // window.innerHeight) {iframe.style.height = window.innerHeight + "px";}break;case "reloadPage":window.location.reload();break;}};if (window.addEventListener) {window.addEventListener("message", handleIFrameMessage, false);} else if (window.attachEvent) {window.attachEvent("onmessage", handleIFrameMessage);} // ]]>



    This is a re-post of a comment on Getting the Form iFrame Code

  • Profile Image
    Ben
    Answered on July 20, 2015 at 10:01 AM

    Based on the code that you have mentioned, it seems that you are only adding the javascript code to your website without the iframe code that is right above it.

    That is why the code is not showing your form.

    Please note that your form should look similar to this one (but with the link to your own form):

    <iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="//form.jotformpro.com/form/52003848541956" frameborder="0" style="width:100%; height:514px; border:none;" scrolling="no"></iframe>
    <script type="text/javascript">window.handleIFrameMessage = function(e) {var args = e.data.split(":");var iframe = document.getElementById("JotFormIFrame");if (!iframe)return;switch (args[0]) {case "scrollIntoView":iframe.scrollIntoView();break;case "setHeight":iframe.style.height = args[1] + "px";break;case "collapseErrorPage":if (iframe.clientHeight > window.innerHeight) {iframe.style.height = window.innerHeight + "px";}break;case "reloadPage":window.location.reload();break;}};if (window.addEventListener) {window.addEventListener("message", handleIFrameMessage, false);} else if (window.attachEvent) {window.attachEvent("onmessage", handleIFrameMessage);}</script>

    I have marked with bold the parts that are missing from your own code.

    I would suggest trying the same steps to get the code once again and if it is still not working, do let us know the link to the page where the form is embedded so that we can take a further look into it for you.