Earlier provided Jotform Embed code is not loading the second page of jotform by using onDISABLEDload="window.parent.scrollTo(0,0)"

  • Torre
    Asked on May 1, 2024 at 1:08 PM

    Jotform support team provided embed code for one of the earlier support tickets. However, when the form is embed in to external website using this embed code, the second page of the form "Onload" is not loading by scrolling to the top of the page as a result, the clients need to scroll up in order to fill the form. The same behavior is shown when back button is pressed. where in the first page is not fully scroll up at the time of page load.

    Support team specifically gave the onDISABLEDload="window.parent.scrollTo(0,0)" for it to go to the top I believe. However, that is not delivering the expected result.


    Here is the code given by the support team.

    <iframe

    id="JotFormIFrame-222925432041144"

    title=" (Live) How-To-Live Online Program Registration Dec  2022"

    onDISABLEDload="window.parent.scrollTo(0,0)"

    allowtransparency="true"

    allowfullscreen="true"

    allow="geolocation; microphone; camera"

    src="https://form.jotform.com/222925432041144"

    frameborder="0"

    style="

          min-width: 100%;

          height:539px;

          border:none;"

    scrolling="no"

        >

        </iframe>

        <script type="text/javascript">

    var ifr = document.getElementById("JotFormIFrame-222925432041144");



    let c=0;

        ifr.onload = (e=>{

    if(c==0){

              c++;

         }else{

            ifr.style.height="529px";

            ifr.scrollTo(0,0);

        }

        }); 

    if (ifr) {

    var src = ifr.src;

    var iframeParams = [];

    if (window.location.href && window.location.href.indexOf("?") > -1) {

              iframeParams = iframeParams.concat(window.location.href.substr(window.location.href.indexOf("?") + 1).split('&'));

            }

    if (src && src.indexOf("?") > -1) {

              iframeParams = iframeParams.concat(src.substr(src.indexOf("?") + 1).split("&"));

              src = src.substr(0, src.indexOf("?"))

            }

            iframeParams.push("isIframeEmbed=1");

            ifr.src = src + "?" + iframeParams.join('&');

          }

    window.handleIFrameMessage = function(e) {

    if (typeof e.data === 'object') { return; }

    var args = e.data.split(":");

    if (args.length > 2) { iframe = document.getElementById("JotFormIFrame-" + args[(args.length - 1)]); } else { 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;

    case "loadScript":

    if( !window.isPermitted(e.origin, ['jotform.com', 'jotform.pro']) ) { break; }

    var src = args[1];

    if (args.length > 3) {

                    src = args[1] + ':' + args[2];

                }

    var script = document.createElement('script');

                script.src = src;

                script.type = 'text/javascript';

    document.body.appendChild(script);

    break;

    case "exitFullscreen":

    if      (window.document.exitFullscreen)        window.document.exitFullscreen();

    else if (window.document.mozCancelFullScreen)   window.document.mozCancelFullScreen();

    else if (window.document.mozCancelFullscreen)   window.document.mozCancelFullScreen();

    else if (window.document.webkitExitFullscreen)  window.document.webkitExitFullscreen();

    else if (window.document.msExitFullscreen)      window.document.msExitFullscreen();

    break;

            }

    var isJotForm = (e.origin.indexOf("jotform") > -1) ? true : false;

    if(isJotForm && "contentWindow" in iframe && "postMessage" in iframe.contentWindow) {

    var urls = {"docurl":encodeURIComponent(document.URL),"referrer":encodeURIComponent(document.referrer)};

              iframe.contentWindow.postMessage(JSON.stringify({"type":"urls","value":urls}), "*");

            }

          };

    window.isPermitted = function(originUrl, whitelisted_domains) {

    var url = document.createElement('a');

            url.href = originUrl;

    var hostname = url.hostname;

    var result = false;

    if( typeof hostname !== 'undefined' ) {

              whitelisted_domains.forEach(function(element) {

    if( hostname.slice((-1 * element.length - 1)) === '.'.concat(element) ||  hostname === element ) {

                      result = true;

                  }

              });

    return result;

            }

          };

    if (window.addEventListener) {

    window.addEventListener("message", handleIFrameMessage, false);

          } else if (window.attachEvent) {

    window.attachEvent("onmessage", handleIFrameMessage);

          }

    </script>

     


  • Joeni JotForm Support
    Replied on May 1, 2024 at 1:29 PM

    Hi Torre,

    Thanks for reaching out to Jotform Support. I'm sorry that this is happening. Can you please share with us the link where your form is embedded?

    Once we hear back from you, we'll be able to help you with this.

 
Your Answer