iFrame embed code changes height value

  • Profile Image
    WISSF
    Asked on May 13, 2015 at 02:07 PM

    Using iFrame embedding.

    I've added CSS to the enclosing box in Visual Composer... and I've added custom CSS in Jotform to make the height right. The iFrame code says 700px... but when the page renders the height reverts to 280px for some reason. WHY?

  • Profile Image
    Charlie
    Answered on May 13, 2015 at 02:57 PM

    It seems like the "onload" function causes the iFrame to revert or inherit other height field.

    Can you try this, copy your iFrame embed code here: http://www.jotform.com/help/148-Getting-the-Form-iFrame-Code.

    In my case, this is how I will edit it:

    Before:

    <iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="//form.jotformpro.com/form/50885628517971" 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>

    After:

    <iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="//form.jotformpro.com/form/50885628517971" frameborder="0" style="width:100%; height:700px !important; border:none;" scrolling="no"></iframe>

     

    I've removed the <script> code that was included on it, then set the height inside the iFrame code to 700px and added "!important" tag. Also, please do remove the custom CSS code that you added inside the form to avoid conflicts.

    Please do let us know if this works.

    Thank you.