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

  • Profile Image
    kochujohnk
    Asked 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.

     

     

     

     

     

  • Profile Image
    liyam
    Answered 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
    kochujohnk
    Answered 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
    Welvin
    Answered 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.