Can an automatic redirection be made on our thank you page?

  • slleykersxx
    Asked on April 20, 2016 at 3:47 PM

    Another Doubt : Include automatic redirection after a few seconds , on the same screen below the image ?

     

    Can an automatic redirection be made on our thank you page? Image 1 Screenshot 20

     

  • Ben
    Replied on April 20, 2016 at 4:25 PM

    Usually that would not be possible, but it might be possible due to the way you have used to embed the form on your website: stipesquisa.esy.es

    What I would suggest to try is the following JavaScript code:

     <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":
                if(args[1] == 437){
              customHeight = 600;
              }else{
              customHeight = args[1];
              }
                iframe.style.height = customHeight + "px";
                break;
              case "collapseErrorPage":
                if (iframe.clientHeight > window.innerHeight) {
                  iframe.style.height = window.innerHeight + "px";
                }
                break;
              case "reloadPage":
                window.location.reload();
                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}), "*");
            }
            var isThankyou = (e.origin.indexOf('submit') > -1) ? true:false;
            if(isThankyou) { setTimeout( function() { window.location.replace('VALID LINK TO REDIRECT TO'); } , 3000); }
          };
          if (window.addEventListener) {
            window.addEventListener("message", handleIFrameMessage, false);
          } else if (window.attachEvent) {
            window.attachEvent("onmessage", handleIFrameMessage);
          }
          if(window.location.href && window.location.href.indexOf("?") > -1) {
            var ifr = document.getElementById("JotFormIFrame");
            var get = window.location.href.substr(window.location.href.indexOf("?") + 1);
            if(ifr && get.length > 0) {
              var src = ifr.src;
              src = src.indexOf("?") > -1 ? src + "&" + get : src  + "?" + get;
              ifr.src = src;
            }
          }
          </script>

    - This code should go instead of the current Javascript code - the one right under the iframe code on your page.

    I had made it check if it is the thank you page and then if it is, to redirect after 3 seconds.

    It is however important to change VALID LINK TO REDIRECT TO above to the actual link to avoid any issues and the reason why I had set it to 3 seconds is to allow the thank you page to load, otherwise it would do it too quickly.

    Please do test it out and let us know how it goes.

  • slleykersxx
    Replied on April 20, 2016 at 5:48 PM

    Everything functioning normally .. Thank you very much the same . 

     

    I thank you

  • liyam
    Replied on April 20, 2016 at 8:16 PM

    On behalf of my colleague, you are welcome :)

    If you have other questions or concerns, please do let us know.

    Thanks and warm regards.