What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Pop up Box during refresh and closing the tab or browser by mistake

    Asked by kochujohnk on March 08, 2017 at 05:57 PM

    Hello,

    I have another question.

    1) Is there a way to add a dialog box (pop up box) if the user clicks on the close button in the browser by mistake or if they close the tab by mistake while the test is being run?

    2) Also, is there a way to have a pop up box that prompts the user when they refresh the form

    Please do help me with this.

     

     

     

     

     

    Page URL:
    https://www.jotform.com/build/70645043113445

  • Profile Image
    JotForm Support

    Answered by liyam on March 08, 2017 at 08:33 PM

    Hello,

    Unfortunately, this is not possible to be inserted directly to your form. You will need to get your form's full HTML source code and place the code on a different web page. After doing so, you can insert this javascript code into your form:

    <script type="text/javascript">
        window.onbeforeunload = function() { return "Are you sure you want to leave?"; }
    </script>

    You can check this guide for more information on how to get your form's full HTML source: https://www.jotform.com/help/104-How-to-get-the-Full-Source-Code-of-your-Form

    Note: what this script does is it prompts the user if the browser is to be unloaded. This means if the user presses the refresh button or wishes to leave the page.

    If you have questions, please let us know.

    Thanks.

  • Profile Image

    Answered by kochujohnk on March 09, 2017 at 10:31 AM

    When you say "place the code on a different web page." what do you mean by that? Please explain me how to do that. 

     

    Also where in the entire code should i be copy pasting this 

    <script type="text/javascript">

        window.onbeforeunload = function() { return "Are you sure you want to leave?"; }
    </script>

     

    Please guide me on this. 

  • Profile Image
    JotForm Support

    Answered by Welvin on March 09, 2017 at 06:41 PM

    You have to create a new page on your website and place the form source codes there. Are you using a CMS like WordPress or a static HTML? 

    As for the script, you can add it at the top or bottom of the form source codes.