Automatically refreshing the web page once only

  • Profile Image
    bigpicturecomp
    Asked on March 13, 2015 at 09:33 PM
    The next question is whether I can force the page to reload once. This error in how the page loads is on the jotform side. The only embed option that works properly is the iframe option. But, I can't use that option as the page then does not translate into another language.
  • Profile Image
    Jan
    Answered on March 14, 2015 at 02:09 AM

    Hi there,

    If I understand you correctly, you want the embedded form to reload once the web page is loaded completely right? Also, you can't use iFrame method right?

    Unfortunately, this is not possible inside JotForm. You will need to edit the web page source code itself. The solution will be to use Javascript code that will automatically refresh the whole web page once it is completely loaded. 

    If you add this code in the body tag. the web page keeps on refreshing like a loop.

    <body onload="window.location.reload()">

    I tried searching for a Javascript code or for a condition that will make it stop. I found a ways to do it but when I test it, they are not working.

    I'm sorry but it is not possible to refresh the page 1 time once the page is completely loaded. Please check this web page for page refresh using Javascript.

    Thank you.

  • Profile Image
    bigpicturecomp
    Answered on March 14, 2015 at 03:34 AM

    Thanks Jan,

      That is an interesting stragety. From reading through the information you provide, I can see that it is possible to make a page load once after a visitor visits the page for the first time. I'm not 100% sure how to get there just yet, but it would clearly require setting a cookie to get there. A javasrcipt that asks if a cookie exists, if no.... set cookie and refresh the page... then the cookie would exist and the reload would not be executed again. This would break the loop you experienced.

    Hmmmm.... how to make that happen?

  • Profile Image
    abajan
    Answered on March 14, 2015 at 04:03 AM

    Hi again,

    I was able to find a script that does this. Initially, it seemed not to work but I discovered that it does work, just too quickly for the eye. The page reload can be delayed with setTimeout() like in this demo.

    If you need further help with this, please let us know.

     

    Thanks

  • Profile Image
    bigpicturecomp
    Answered on March 14, 2015 at 04:13 AM

    Thanks abajan!!!

     

    I just finished testing this which worked as well...

     

    <script type="text/javascript">
    if(location.search.indexOf('r') < 0){
        var hash = window.location.hash;
        var loc = window.location.href.replace(hash, '');
        loc += (loc.indexOf('?') < 0? '?' : '&') + 'r';
        setTimeout(function(){window.location.href = loc + hash;}, 2000);
    }
    </script>

  • Profile Image
    Jan
    Answered on March 14, 2015 at 05:28 AM

    I'm glad to hear that Abajan resolved this issue.

    On behalf of Abajan, you are welcome.  Let us know if you need any help.

    Thank you.

  • Profile Image
    bigpicturecomp
    Answered on March 14, 2015 at 02:00 PM

    Thanks Jan.

     

       Whlie it worked... it does not resolve the issue. I tested many times and a couple of times. It loaded correctly the first time and then after the forced reload, the problem occurred. The solution is for the conflict to be fixed on the jotform side. Oh well... I guess I will have to live wit the problem and hope my visitors figure it out. (I get lots of confused emails from people.)

    :(

  • Profile Image
    bigpicturecomp
    Answered on April 01, 2015 at 08:07 PM

    This issue has never been resolved. :(

  • Profile Image
    raul
    Answered on April 01, 2015 at 10:37 PM

    I'm sorry to see that your issue wasn't resolved yet.

    I see that you already replied on the original thread: http://www.jotform.com/answers/532335 so please refer to that thread since it has more information about the issue and this thread is referencing to the possibility to automatically refresh a page only one time.

    Thank you.